Update 2 files

- /Jenkinsfile
- /.gitlab-ci.yml
This commit is contained in:
Luca Lutz 2023-06-26 11:01:11 +00:00
parent fd056321d3
commit 4e6ab5f91c
2 changed files with 19 additions and 54 deletions

19
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,19 @@
variables:
SFZ_REGISTRY_IMAGE: $SFZ_REGISTRY/$CI_PROJECT_PATH
docker-build:
image: quay.io/podman/stable
stage: build
before_script:
- podman login -u "$SFZ_REGISTRY_USER" -p "$SFZ_REGISTRY_PASSWORD" $SFZ_REGISTRY
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- tag=$(date +%s)
- podman build --pull -t "$SFZ_REGISTRY_IMAGE:${tag}" .
- podman push "$SFZ_REGISTRY_IMAGE:${tag}"
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile

54
Jenkinsfile vendored
View File

@ -1,54 +0,0 @@
pipeline {
agent any
post {
failure {
updateGitlabCommitStatus name: 'build', state: 'failed'
}
success {
updateGitlabCommitStatus name: 'build', state: 'success'
}
aborted {
updateGitlabCommitStatus name: 'build', state: 'canceled'
}
}
options {
gitLabConnection('GitLab')
}
triggers {
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All')
}
stages {
stage("build") {
steps {
updateGitlabCommitStatus name: 'build', state: 'running'
podTemplate(
containers: [
containerTemplate(name: 'docker-image-build', image: 'mgoltzsche/podman', ttyEnabled: true, command: 'cat', privileged: true),
]) {
node(POD_LABEL) {
updateGitlabCommitStatus name: 'build', state: 'pending'
checkout([$class: 'GitSCM', branches: [
[name: '*/main']
], userRemoteConfigs: [
[url: 'https://gitlab.com/luca_lutz/fabaccess.git']
]])
container('docker-image-build') {
withCredentials([
usernamePassword(credentialsId: 'docker.credentials',
usernameVariable: 'DOCKER_USERNAME',
passwordVariable: 'DOCKER_PASSWORD')
]) {
sh 'echo $(date +%s) > /time'
sh 'echo "nameserver 10.12.42.2" > /etc/resolv.conf'
sh 'podman build --tag docker.sfz-aalen.space/hackwerk/fabaccess:$(cat /time) .'
sh 'podman login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD} docker.sfz-aalen.space'
sh 'podman push docker.sfz-aalen.space/hackwerk/fabaccess:$(cat /time)'
}
}
}
}
}
}
}
}