From de98afcd9373e2f1f9884e569003585cc80fed41 Mon Sep 17 00:00:00 2001 From: moleksiienko Date: Tue, 14 Jan 2025 00:04:42 +0200 Subject: [PATCH] build fixed, deploy job done --- cicd/jenkins-pipelines/build.groovy | 10 +++++----- cicd/jenkins-pipelines/deploy.groovy | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 cicd/jenkins-pipelines/deploy.groovy diff --git a/cicd/jenkins-pipelines/build.groovy b/cicd/jenkins-pipelines/build.groovy index eae304ee7..bae4c8a46 100644 --- a/cicd/jenkins-pipelines/build.groovy +++ b/cicd/jenkins-pipelines/build.groovy @@ -1,11 +1,11 @@ pipeline { agent any -// triggers { -// pollSCM('H/5 * * * *') // Watches the `dev` branch -// } + triggers { + pollSCM('H/5 * * * *') // Watches the `dev` branch + } environment { - DOCKERHUB_CREDENTIALS = credentials('nalexxgd_docker_pass') - DOCKERHUB_USERNAME = "nalexxgd" + DOCKERHUB_CREDENTIALS = credentials('nalexx6_docker_pass') + DOCKERHUB_USERNAME = "nalexx6" NEXUS_URL = 'localhost:8081' def ARTIFACT_VERSION = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim() diff --git a/cicd/jenkins-pipelines/deploy.groovy b/cicd/jenkins-pipelines/deploy.groovy new file mode 100644 index 000000000..d32fdc5fb --- /dev/null +++ b/cicd/jenkins-pipelines/deploy.groovy @@ -0,0 +1,21 @@ +pipeline { + agent any + parameters { + string(name: 'ARTIFACT_VERSION', description: 'Version of the artifact to deploy') + } + environment { + DOCKERHUB_USERNAME = "nalexx6" + } + stages { + stage('Pull Docker Image') { + steps { + sh "docker pull ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}" + } + } + stage('Run Docker Container') { + steps { + sh "docker run -d -p 80:8080 ${DOCKERHUB_USERNAME}/petclinic:${ARTIFACT_VERSION}" + } + } + } +}