Skip to content

Commit e0c0d6d

Browse files
committed
In the build of the docker image silverbuild, fix the case no changes has been done in the Dockerfile before tagging the project
1 parent a38321f commit e0c0d6d

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/releases/docker-build/Jenkinsfile

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,26 @@ pipeline {
7575
}
7676
steps {
7777
sh 'git config --local credential.helper "!f() { echo username=\\${GIT_AUTH_USR}; echo password=\\$GIT_AUTH_PSW; }; f"'
78-
sh """
79-
sed -i -e "s/WILDFLY_VERSION=[0-9.]\\+/WILDFLY_VERSION=${params.WILDFLY_VERSION}/g" Dockerfile
80-
sed -i -e "s/JAVA_VERSION=[0-9]\\+/JAVA_VERSION=${params.JAVA_VERSION}/g" Dockerfile
81-
sed -i -e "s/SONAR_JAVA_VERSION=[0-9]\\+/SONAR_JAVA_VERSION=${params.SONAR_JAVA_VERSION}/g" Dockerfile
82-
sed -i -e "s/version=[0-9.]\\+/version=${params.IMAGE_VERSION}/g" Dockerfile
83-
sed -i -e "s/build=.\\+/build=1/g" Dockerfile
84-
git commit -am "Update Dockerfile for building and registering image ${params.IMAGE_VERSION}"
85-
git push origin HEAD:master
86-
git tag ${params.IMAGE_VERSION}
87-
git push origin --tags
88-
"""
78+
script {
79+
String status = sh script: """
80+
sed -i -e "s/WILDFLY_VERSION=[0-9.]\\+/WILDFLY_VERSION=${params.WILDFLY_VERSION}/g" Dockerfile
81+
sed -i -e "s/JAVA_VERSION=[0-9]\\+/JAVA_VERSION=${params.JAVA_VERSION}/g" Dockerfile
82+
sed -i -e "s/SONAR_JAVA_VERSION=[0-9]\\+/SONAR_JAVA_VERSION=${params.SONAR_JAVA_VERSION}/g" Dockerfile
83+
sed -i -e "s/version=[0-9.]\\+/version=${params.IMAGE_VERSION}/g" Dockerfile
84+
sed -i -e "s/build=.\\+/build=1/g" Dockerfile
85+
git diff --quiet
86+
""", returnStatus: true
87+
if (status == '1') {
88+
sh """
89+
git commit -am "Update Dockerfile for building and registering image ${params.IMAGE_VERSION}"
90+
git push origin HEAD:master
91+
"""
92+
}
93+
sh """
94+
git tag ${params.IMAGE_VERSION}
95+
git push origin --tags
96+
"""
97+
}
8998
}
9099
}
91100
stage('Update current latest version') {

0 commit comments

Comments
 (0)