From ae7d75c6f1ca9d208c9089222fb6d0e57a3d7c4a Mon Sep 17 00:00:00 2001 From: shashi kumar Date: Thu, 24 Jul 2025 21:45:59 +0530 Subject: [PATCH] modifyig the jenkinsfile --- jenkins-setup/docker-compose.yaml | 1 - jenkins-setup/jenkins/casc.yaml | 2 +- jenkins-setup/pipelines/Jenkinsfile | 63 ++++++++++++++++++++++++++++- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/jenkins-setup/docker-compose.yaml b/jenkins-setup/docker-compose.yaml index 6cec30c..7d51b0a 100644 --- a/jenkins-setup/docker-compose.yaml +++ b/jenkins-setup/docker-compose.yaml @@ -15,7 +15,6 @@ services: volumes: - jenkins_home:/var/jenkins_home - ./jenkins/casc.yaml:/var/jenkins_home/casc/casc.yaml - - ./pipelines:/var/jenkins_home/pipelines - /var/run/docker.sock:/var/run/docker.sock volumes: jenkins_home: diff --git a/jenkins-setup/jenkins/casc.yaml b/jenkins-setup/jenkins/casc.yaml index 4944c44..224704b 100644 --- a/jenkins-setup/jenkins/casc.yaml +++ b/jenkins-setup/jenkins/casc.yaml @@ -25,7 +25,7 @@ jobs: remote { url("https://github.com/mastershashi/devOps.git") } - branches("*/main") + branches("*/master") } } scriptPath("jenkins-setup/pipelines/Jenkinsfile") diff --git a/jenkins-setup/pipelines/Jenkinsfile b/jenkins-setup/pipelines/Jenkinsfile index d7a9e39..1638620 100644 --- a/jenkins-setup/pipelines/Jenkinsfile +++ b/jenkins-setup/pipelines/Jenkinsfile @@ -1,19 +1,78 @@ pipeline { agent any + + environment { + DOCKER_IMAGE = "yourdockerhubuser/yourapp" + DOCKER_TAG = "latest" + } + stages { stage('Build') { steps { echo "โœ… Building the app..." + // build your app here } } + stage('Test') { steps { echo "๐Ÿงช Running tests..." + // run tests here + } + } + + stage('Docker Build') { + steps { + script { + echo "๐Ÿณ Building Docker image..." + sh "docker build -t $DOCKER_IMAGE:$DOCKER_TAG ." + } + } + } + + stage('Push to Docker Hub') { + steps { + withCredentials([usernamePassword(credentialsId: 'dockerhub-creds', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) { + sh """ + echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin + docker push $DOCKER_IMAGE:$DOCKER_TAG + """ + } + } + } + + stage('Deploy to Dev/Staging') { + steps { + echo "๐Ÿš€ Deploying to staging environment..." + // deployment script/command + } + } + + stage('Approval & Deploy to EU10') { + steps { + input message: "Deploy to EU10?", ok: "Deploy" + echo "๐Ÿš€ Deploying to EU10..." + } + } + + stage('Approval & Deploy to EU20') { + steps { + input message: "Deploy to EU20?", ok: "Deploy" + echo "๐Ÿš€ Deploying to EU20..." + } + } + + stage('Approval & Deploy to US10') { + steps { + input message: "Deploy to US10?", ok: "Deploy" + echo "๐Ÿš€ Deploying to US10..." } } - stage('Deploy') { + + stage('Approval & Deploy to US20') { steps { - echo "๐Ÿš€ Deploying to environment..." + input message: "Deploy to US20?", ok: "Deploy" + echo "๐Ÿš€ Deploying to US20..." } } }