From 6d5aa883460e07e85645ebde97a5e8b80589edba Mon Sep 17 00:00:00 2001 From: manasa Date: Sun, 3 Mar 2024 16:40:31 +0530 Subject: [PATCH 1/3] Add Jenkinsfile --- Jenkinsfile | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..a6c56de --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,78 @@ +pipeline { + environment { + devRegistry = 'ghcr.io/datakaveri/rs-dev' + deplRegistry = 'ghcr.io/datakaveri/rs-depl' + registryUri = 'https://ghcr.io' + registryCredential = 'datakaveri-ghcr' + GIT_HASH = GIT_COMMIT.take(7) + } + + agent { + node { + label 'slave1' + } + } + + stages { + stage('Build images') { + steps { + script { + echo 'Pulled - ' + env.GIT_BRANCH + devImage = docker.build(devRegistry, "-f vertx/docker/dev.dockerfile .") + deplImage = docker.build(deplRegistry, "-f vertx/docker/depl.dockerfile .") + } + } + } + stage('Continuous Deployment') { + when { + allOf { + anyOf { + changeset "docker/**" + changeset "docs/**" + changeset "pom.xml" + changeset "src/main/**" + triggeredBy cause: 'UserIdCause' + } + expression { + return env.GIT_BRANCH == 'origin/master'; + } + } + } + stages { + stage('Push Images') { + steps { + script { + docker.withRegistry( registryUri, registryCredential ) { + devImage.push("5.0.0-${env.GIT_HASH}") + deplImage.push("5.0.0-${env.GIT_HASH}") + } + } + } + } + stage('Docker Swarm deployment') { + steps { + script { + sh "ssh azureuser@docker-swarm 'docker service update lip_lip --image ghcr.io/datakaveri/lip-depl:5.0.0-${env.GIT_HASH}'" + sh 'sleep 10' + } + } + post { + failure { + error "Failed to deploy image in Docker Swarm" + } + } + } + } + post { + failure { + script { + if (env.GIT_BRANCH == 'origin/master') { + emailext recipientProviders: [buildUser(), developers()], to: '$RS_RECIPIENTS, $DEFAULT_RECIPIENTS', subject: '$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!', body: '''$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS: + Check console output at $BUILD_URL to view the results.''' + } + } + } + } + } + } +} From ff7c60ca99362da2762ce39216d3794ed29bf859 Mon Sep 17 00:00:00 2001 From: manasa Date: Mon, 4 Mar 2024 16:21:01 +0530 Subject: [PATCH 2/3] Update Jenkinsfile and build badge to README.md --- Jenkinsfile | 15 +++++++-------- README.md | 2 ++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a6c56de..7516ccc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { environment { - devRegistry = 'ghcr.io/datakaveri/rs-dev' - deplRegistry = 'ghcr.io/datakaveri/rs-depl' + devRegistry = 'ghcr.io/datakaveri/lip-dev' + deplRegistry = 'ghcr.io/datakaveri/lip-depl' registryUri = 'https://ghcr.io' registryCredential = 'datakaveri-ghcr' GIT_HASH = GIT_COMMIT.take(7) @@ -17,7 +17,6 @@ pipeline { stage('Build images') { steps { script { - echo 'Pulled - ' + env.GIT_BRANCH devImage = docker.build(devRegistry, "-f vertx/docker/dev.dockerfile .") deplImage = docker.build(deplRegistry, "-f vertx/docker/depl.dockerfile .") } @@ -27,7 +26,7 @@ pipeline { when { allOf { anyOf { - changeset "docker/**" + changeset "vertx/**" changeset "docs/**" changeset "pom.xml" changeset "src/main/**" @@ -43,8 +42,8 @@ pipeline { steps { script { docker.withRegistry( registryUri, registryCredential ) { - devImage.push("5.0.0-${env.GIT_HASH}") - deplImage.push("5.0.0-${env.GIT_HASH}") + devImage.push("5.5.0-alpha-${env.GIT_HASH}") + deplImage.push("5.5.0-alpha-${env.GIT_HASH}") } } } @@ -52,7 +51,7 @@ pipeline { stage('Docker Swarm deployment') { steps { script { - sh "ssh azureuser@docker-swarm 'docker service update lip_lip --image ghcr.io/datakaveri/lip-depl:5.0.0-${env.GIT_HASH}'" + sh "ssh azureuser@docker-swarm 'docker service update lip_lip --image ghcr.io/datakaveri/lip-depl:5.5.0-alpha-${env.GIT_HASH}'" sh 'sleep 10' } } @@ -75,4 +74,4 @@ pipeline { } } } -} +} \ No newline at end of file diff --git a/README.md b/README.md index 44bf23b..c961352 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://img.shields.io/jenkins/build?jobUrl=https://jenkins.iudx.io/view/iudx-master/job/iudx%20lip%20(master)%20pipeline/)](https://jenkins.iudx.io/view/iudx-master/job/iudx%20lip%20(master)%20pipeline/lastBuild/) + ![IUDX](./images/iudx.png) # Latest Ingestion Pipeline From 29ddcefaf1be32763a1d3cfea14cc2b73b47d7f2 Mon Sep 17 00:00:00 2001 From: manasa Date: Mon, 4 Mar 2024 16:42:19 +0530 Subject: [PATCH 3/3] Update Jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7516ccc..011f26d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,10 +26,10 @@ pipeline { when { allOf { anyOf { - changeset "vertx/**" - changeset "docs/**" - changeset "pom.xml" - changeset "src/main/**" + changeset "vertx/docker/**" + changeset "vertx/docs/**" + changeset "vertx/pom.xml" + changeset "vertx/src/main/**" triggeredBy cause: 'UserIdCause' } expression {