|
|
@@ -10,46 +10,47 @@ pipeline {
|
|
|
stages {
|
|
|
// ... (autres stages inchangés)
|
|
|
|
|
|
- stage('Docker Registry Login, Pull, and Push') {
|
|
|
- when {
|
|
|
- branch 'dev'
|
|
|
- }
|
|
|
- steps {
|
|
|
- script {
|
|
|
- def registryUrl = 'nexus.foodgame.fr:8123'
|
|
|
- def imageName = 'quay.io/prometheus/node-exporter'
|
|
|
- def imageVersion = 'latest'
|
|
|
+ // stage('Docker Registry Login, Pull, and Push') {
|
|
|
+ // when {
|
|
|
+ // branch 'dev'
|
|
|
+ // }
|
|
|
+ // steps {
|
|
|
+ // script {
|
|
|
+ // def registryUrl = 'nexus.foodgame.fr:8123'
|
|
|
+ // def imageName = 'quay.io/prometheus/node-exporter'
|
|
|
+ // def imageVersion = 'latest'
|
|
|
|
|
|
- docker.withRegistry("https://${registryUrl}", 'nexus') {
|
|
|
- try {
|
|
|
- // Try pulling the image from the registry
|
|
|
- echo "Trying to pull image: ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
- docker.image("${registryUrl}/${imageName}:${imageVersion}").pull()
|
|
|
- } catch (Exception e) {
|
|
|
- echo "Image pull failed. Attempting to build and push."
|
|
|
+ // docker.withRegistry("https://${registryUrl}", 'nexus') {
|
|
|
+ // try {
|
|
|
+ // // Try pulling the image from the registry
|
|
|
+ // echo "Trying to pull image: ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
+ // docker.image("${registryUrl}/${imageName}:${imageVersion}").pull()
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // echo "Image pull failed. Attempting to build and push."
|
|
|
|
|
|
- // Pull base image from Docker Hub
|
|
|
- echo "Pulling base image: ${imageName}:${imageVersion}"
|
|
|
- sh "docker pull ${imageName}:${imageVersion}"
|
|
|
+ // // Pull base image from Docker Hub
|
|
|
+ // echo "Pulling base image: ${imageName}:${imageVersion}"
|
|
|
+ // sh "docker pull ${imageName}:${imageVersion}"
|
|
|
|
|
|
- // Tag the image for the private registry
|
|
|
- echo "Tagging image for private registry"
|
|
|
- sh "docker tag ${imageName}:${imageVersion} ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
+ // // Tag the image for the private registry
|
|
|
+ // echo "Tagging image for private registry"
|
|
|
+ // sh "docker tag ${imageName}:${imageVersion} ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
|
|
|
- // Push the tagged image to the private registry
|
|
|
- echo "Pushing image to private registry"
|
|
|
- sh "docker push ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // // Push the tagged image to the private registry
|
|
|
+ // echo "Pushing image to private registry"
|
|
|
+ // sh "docker push ${registryUrl}/${imageName}:${imageVersion}"
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
stage('Build & Deploy') {
|
|
|
steps {
|
|
|
sh '''
|
|
|
docker-compose stop
|
|
|
- docker-compose build
|
|
|
- docker-compose up -d
|
|
|
+ docker-compose build --no-cache
|
|
|
+ docker-compose up -d --force-recreate
|
|
|
+
|
|
|
'''
|
|
|
}
|
|
|
}
|