From 615cbc359658846bcbe5704d5c6139fdedce7ad0 Mon Sep 17 00:00:00 2001 From: Luca Lutz Date: Tue, 1 Nov 2022 21:57:16 +0000 Subject: [PATCH] Add new file --- Jenkinsfile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..0a62865 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,54 @@ +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)' + } + } + } + } + } + } + } +} +