diff --git a/Jenkinsfile b/Jenkinsfile index 8c10153cbfad1402cf4673b5e79a06fd92cb7196..ea6ecbd8001fa6ed2f21f36fa4f891d1b861c1a5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,9 @@ node() { stage('Checkout') { cleanWs() checkout scm + commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + env.commit_id = sh(script: "echo " + "user" + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim() + echo "${env.commit_id}" } } stage('docker-pre-build') { @@ -24,20 +27,22 @@ node() { stage('docker-build') { sh ''' - commit_id=$(git rev-parse --short HEAD) - echo $commit_id> commit_id.txt docker build --no-cache -f Dockerfile -t $docker_server/$docker_repo:$commit_id . ''' } stage('docker-push') { sh ''' - pwd - commit_id=$(git rev-parse --short HEAD) docker push $docker_server/$docker_repo:$commit_id docker rmi -f $docker_server/$docker_repo:$commit_id ''' } + stage('ArchiveArtifacts') { + sh ("echo ${commit_id} > commit_id.txt") + archiveArtifacts "commit_id.txt" + currentBuild.description = "${commit_id}" + } + } catch (err) {