diff --git a/Jenkinsfile b/Jenkinsfile index 452c8a17c..348cda85c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stage('Build') { agent { docker { - image 'maven:3.5.0' + image 'maven:3.3.0' args '--network=pipelinedeveloper_default' } } @@ -15,26 +15,18 @@ pipeline { } } } - stage('Build container') { - agent any - steps { - sh 'docker build -t petclinic-tomcat .' - } - } - stage('Deploy container locally') { - agent any - steps { - sh 'docker rm -f petclinic-tomcat-temp || true' - sh 'docker run -p 18887:8080 -d --name petclinic-tomcat-temp petclinic-tomcat' - echo 'Should be available at http://localhost:18887/petclinic/' - } - } - stage('Stop Container') { - agent any - steps { - input 'Stop container?' - sh 'docker rm -f petclinic-tomcat-temp || true' - } - } + stage('Deploy') { + agent { + docker { + image 'liatrio/cf-cli' + } + } + steps { + withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { + sh "cf api https://api.run.pivotal.io && cf login -u ${env.USERNAME} -p ${env.PASSWORD}" + sh 'cf push' + } + } + } } } diff --git a/jenkinsfiles/pivotal b/jenkinsfiles/pivotal index 33ba5411e..e62e061db 100644 --- a/jenkinsfiles/pivotal +++ b/jenkinsfiles/pivotal @@ -1,3 +1,4 @@ +#!groovy pipeline { agent none stages { @@ -11,22 +12,40 @@ pipeline { steps { configFileProvider( [configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { - sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B' + sh 'mvn -s $MAVEN_SETTINGS clean install -DskipTests=true -B' } } } - stage('Deploy to Pivotal') { + stage('Deploy to Pivotal Development') { agent { docker { image 'liatrio/cf-cli' + args '-u 0:0' } } steps { - withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]){ - sh "cf api https://api.run.pivotal.io && cf login -u ${env.USERNAME} -p ${env.PASSWORD}" - sh 'cf push' + withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'pivotalPASSWORD', usernameVariable: 'pivotalUSERNAME')]){ + sh "cf api https://api.run.pivotal.io && cf login -u ${env.pivotalUSERNAME} -p ${env.pivotalPASSWORD}" + sh 'cf push -f ./base-manifest.yml' + echo "Should be accessible at http://pivotal-dev.liatr.io" + input 'Deploy to Pivotal Prod?' } + } } + stage('Deploy to Pivotal Prod') { + agent { + docker { + image 'liatrio/cf-cli' + args '-u 0:0' + } + } + steps { + withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'pivotalPASSWORD', usernameVariable: 'pivotalUSERNAME')]){ + sh "cf api https://api.run.pivotal.io && cf login -u ${env.pivotalUSERNAME} -p ${env.pivotalPASSWORD}" + sh 'cf push -f ./prod-manifest.yml' + echo "Should be accessible at http://pivotal-prod.liatr.io" + } + } } } }