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}" + } + } + } +}