|
|
@@ -89,23 +89,32 @@ pipeline {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- stage('Docker Registry Login, Pull, and Push') {
|
|
|
+ stage('Docker Registry Login, Pull, and Push') {
|
|
|
when {
|
|
|
branch 'master'
|
|
|
}
|
|
|
steps {
|
|
|
script {
|
|
|
- docker.withRegistry('https://nexus.foodgame.fr:8123', 'nexus') {
|
|
|
- // Pull image
|
|
|
- docker.image('nexus.foodgame.fr:8123/fatboar_master_express_preprod:latest').pull()
|
|
|
-
|
|
|
- // Push image
|
|
|
- docker.image('nexus.foodgame.fr:8123/fatboar_master_express_preprod:latest').push()
|
|
|
+ def imageName = 'fatboar_master_express_preprod'
|
|
|
+ def registryUrl = 'nexus.foodgame.fr:8123'
|
|
|
+
|
|
|
+ docker.withRegistry("https://${registryUrl}", 'nexus') {
|
|
|
+ try {
|
|
|
+ docker.image("${registryUrl}/${imageName}:latest").pull()
|
|
|
+ } catch (Exception e) {
|
|
|
+ echo "Image pull failed. Attempting to build and push."
|
|
|
+
|
|
|
+ // Build image
|
|
|
+ def customImage = docker.build("${imageName}")
|
|
|
+
|
|
|
+ // Tag and push
|
|
|
+ customImage.tag("${registryUrl}/${imageName}:latest")
|
|
|
+ customImage.push()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
stage('Cleanup') {
|
|
|
steps {
|
|
|
echo "Nettoyage terminé pour la branche ${env.BRANCH_NAME}"
|