From 825804de00db2b3b2ce721d8255d8a18d769cfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 23 Feb 2023 10:58:24 +0100 Subject: [PATCH] Jenkinsfile: add CI Docker image build for Jenkins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'll use `deploy-${env}-${stage}` tags for deploy to Spiff envs. Signed-off-by: Jakub SokoĊ‚owski --- Jenkinsfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..829a3b2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,48 @@ +pipeline { + agent { label 'linux' } + + options { + timestamps() + timeout(time: 20, unit: 'MINUTES') + buildDiscarder(logRotator( + numToKeepStr: '10', + daysToKeepStr: '30', + )) + } + + parameters { + choice( + name: 'IMAGE_TAG', + description: 'Name of Docker tag to push. Chose wisely.', + choices: ['latest', 'deploy-app-dev', 'deploy-mod-dev', 'deploy-app-test', 'deploy-mod-test'], + ) + string( + name: 'IMAGE_NAME', + description: 'Name of Docker image to push.', + defaultValue: params.IMAGE_NAME ?: 'statusteam/spiffworkflow-connector', + ) + } + + stages { + stage('Build') { + steps { script { + image = docker.build( + "${params.IMAGE_NAME}:${env.GIT_COMMIT.take(8)}", + "--label=commit='${env.GIT_COMMIT.take(8)}' ." + ) + } } + } + + stage('Push') { + steps { script { + withDockerRegistry([credentialsId: "dockerhub-statusteam-auto", url: ""]) { + image.push() + image.push(env.IMAGE_TAG) + } + } } + } + } // stages + post { + always { sh 'docker image prune -f' } + } // post +} // pipeline