Refactor Jenkins Pipeline (Publish to Nexus)
MODIFY
Jenkinsfile
Jenkinsfile
@@ -80,7 +80,21 @@ pipeline {
}
}
- stage('Publish nightly builds to NAS1/Nexus') {
+
+ stage('Publish nightly builds to Nexus') {
+ when {
+ anyOf {
+ branch '**/publish-nightly'
+ }
+ }
+ steps {
+ withDockerRegistry([credentialsId: 'nexus', url: "https://gitlab.scheer-group.com:8080"]) {
+ sh './ci/publish-images.sh ${PACKAGE_VERSION} nighty'
+ }
+ }
+ }
+
+ stage('Publish master nightly builds to NAS1/Nexus') {
when {
anyOf {
branch '**/e2e_master'
@@ -98,7 +112,7 @@ pipeline {
]]
withDockerRegistry([credentialsId: 'nexus', url: "https://gitlab.scheer-group.com:8080"]) {
- sh './ci/publish-images.sh ${PACKAGE_VERSION}'
+ sh './ci/publish-images.sh ${PACKAGE_VERSION} latest'
}
}
}

MODIFY
ci/publish-images.sh
ci/publish-images.sh
#!/usr/bin/env bash
-# ./publishImage.sh VERSION RELEASE
+# ./publishImage.sh VERSION TAG
if [[ $2 = "release" ]]; then
docker tag api-mgmt/devportal:$1 gitlab.scheer-group.com:8080/api-mgmt/devportal:$1
docker push gitlab.scheer-group.com:8080/api-mgmt/devportal:$1
docker image rm -f gitlab.scheer-group.com:8080/api-mgmt/devportal:$1
else
- docker tag api-mgmt/devportal:$1 gitlab.scheer-group.com:8080/api-mgmt/devportal:latest
- docker push gitlab.scheer-group.com:8080/api-mgmt/devportal:latest
+ docker tag api-mgmt/devportal:$1 gitlab.scheer-group.com:8080/api-mgmt/devportal:$2
+ docker push gitlab.scheer-group.com:8080/api-mgmt/devportal:$2
fi

Refactor Jenkins Pipeline (Publish to Nexus)