From b513e87b88c3a811f5448474babbbc40b56c54db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Le=20Meur?= <91831478+lemeurherve@users.noreply.github.com> Date: Wed, 20 Apr 2022 21:26:18 +0200 Subject: [PATCH] fix(buildDockerAndPublishImage) annotated tags (#360) Co-authored-by: Damien Duportal --- test/groovy/BuildDockerAndPublishImageStepTests.groovy | 5 ++++- vars/buildDockerAndPublishImage.groovy | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/groovy/BuildDockerAndPublishImageStepTests.groovy b/test/groovy/BuildDockerAndPublishImageStepTests.groovy index cfdd9c77..e38fd4fa 100644 --- a/test/groovy/BuildDockerAndPublishImageStepTests.groovy +++ b/test/groovy/BuildDockerAndPublishImageStepTests.groovy @@ -130,8 +130,11 @@ class BuildDockerAndPublishImageStepTests extends BaseTest { Boolean assertTagPushed(String newVersion) { return assertMethodCallContainsPattern('echo','Configuring credential.helper') \ + && assertMethodCallContainsPattern('echo','Configuring git user and email') \ + && assertMethodCallContainsPattern('sh','git config user.name "${GIT_USERNAME}"') \ + && assertMethodCallContainsPattern('sh','git config user.email "jenkins-infra@googlegroups.com"') \ && assertMethodCallContainsPattern('echo',"Tagging New Version: ${newVersion}") \ - && assertMethodCallContainsPattern('sh',"git tag ${newVersion}") \ + && assertMethodCallContainsPattern('sh',"git tag -a ${newVersion} -m ${testImageName}") \ && assertMethodCallContainsPattern('echo','Pushing Tag') \ && assertMethodCallContainsPattern('sh','git push origin --tags') } diff --git a/vars/buildDockerAndPublishImage.groovy b/vars/buildDockerAndPublishImage.groovy index 22d9d4e8..5bc4c5cd 100644 --- a/vars/buildDockerAndPublishImage.groovy +++ b/vars/buildDockerAndPublishImage.groovy @@ -137,8 +137,12 @@ def call(String imageName, Map userConfig=[:]) { withCredentials([ usernamePassword(credentialsId: "${finalConfig.gitCredentials}", passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME') ]) { + echo "Configuring git user and email" + sh 'git config user.name "${GIT_USERNAME}"' + sh 'git config user.email "jenkins-infra@googlegroups.com"' + echo "Tagging New Version: $nextVersion" - sh "git tag $nextVersion" + sh "git tag -a $nextVersion -m ${imageName}" echo 'Pushing Tag' sh 'git push origin --tags'