diff --git a/build/Jenkinsfile b/build/Jenkinsfile index ee89363ff..2e4786658 100644 --- a/build/Jenkinsfile +++ b/build/Jenkinsfile @@ -85,7 +85,8 @@ stage ('image build and load') { steps { script { pom = readMavenPom file: "pom.xml"; - docker.build registry + ":${pom.version}" + env.POM_VERSION = ${pom.version} + docker.build registry + ":$POM_VERSION" } script { docker.withRegistry( '', REGISTRY_CREDENTIAL ) { @@ -97,6 +98,16 @@ stage ('image build and load') { } } } + post + { + success + { + script + { + env.ARTIFACT_VERSION = $POM_VERSION + } + } + } } } \ No newline at end of file diff --git a/deployment/Jenkinsfile b/deployment/Jenkinsfile new file mode 100644 index 000000000..8a18d6b88 --- /dev/null +++ b/deployment/Jenkinsfile @@ -0,0 +1,40 @@ +pipeline { + agent any + environment { + NEXUS_VERSION = "nexus3" + NEXUS_PROTOCOL = "http" + NEXUS_URL = "172.19.0.3:8081" + NEXUS_REPOSITORY = "maven-nexus-repo" + NEXUS_CREDENTIAL_ID = "e6072e08-87bc-481e-9e4a-55d506546356" + REGISTRY = "http://localhost:8281/repository/docker_snapshots/" + REGISTRY_CREDENTIAL = "deployment" + } + } + triggers { + + } + stages { + stage { + steps { + build job: 'build', parameters: [ + string(name: 'artifact_version', value: env.ARTIFACT_VERSION) + ], wait: true + } + } + stage('run') { + steps { + script { + withCredentials([usernameColonPassword(credentialsId: 'deployment', variable: 'DEPLOYMENT')]) { + sh ''' + curl -u "$DEPLOYMENT" http://${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/org/springframework/samples/spring-petclinic/2.4.2/spring-petclinic-2.4.2.jar >output + (java -jar spring-petclinic-2.4.2.jar --server.port=8083>> server.log 2>&1&) + nohup java -jar spring-petclinic-2.4.2.jar --server.port=8083>> server.log 2>&1& + ''' + } + } + } + } + + } + +} \ No newline at end of file