Skip to content

Commit

Permalink
fix(buildDockerAndPublishImage) annotated tags (jenkins-infra#360)
Browse files Browse the repository at this point in the history
Co-authored-by: Damien Duportal <damien.duportal@gmail.com>
  • Loading branch information
2 people authored and lemeurherveCB committed Jun 1, 2022
1 parent c953c5d commit b513e87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion test/groovy/BuildDockerAndPublishImageStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
6 changes: 5 additions & 1 deletion vars/buildDockerAndPublishImage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b513e87

Please sign in to comment.