deploying to multiple cf environments in pivotal cloud

This commit is contained in:
Benjamin Stein 2017-08-02 11:56:06 -07:00
parent 7cc050a902
commit 358fce454c
2 changed files with 38 additions and 27 deletions

36
Jenkinsfile vendored
View file

@ -4,7 +4,7 @@ pipeline {
stage('Build') { stage('Build') {
agent { agent {
docker { docker {
image 'maven:3.5.0' image 'maven:3.3.0'
args '--network=pipelinedeveloper_default' args '--network=pipelinedeveloper_default'
} }
} }
@ -15,26 +15,18 @@ pipeline {
} }
} }
} }
stage('Build container') { stage('Deploy') {
agent any agent {
steps { docker {
sh 'docker build -t petclinic-tomcat .' image 'liatrio/cf-cli'
} }
} }
stage('Deploy container locally') { steps {
agent any withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) {
steps { sh "cf api https://api.run.pivotal.io && cf login -u ${env.USERNAME} -p ${env.PASSWORD}"
sh 'docker rm -f petclinic-tomcat-temp || true' sh 'cf push'
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'
}
}
} }
} }

View file

@ -1,3 +1,4 @@
#!groovy
pipeline { pipeline {
agent none agent none
stages { stages {
@ -11,22 +12,40 @@ pipeline {
steps { steps {
configFileProvider( configFileProvider(
[configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) { [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 { agent {
docker { docker {
image 'liatrio/cf-cli' image 'liatrio/cf-cli'
args '-u 0:0'
} }
} }
steps { steps {
withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]){ withCredentials([usernamePassword(credentialsId: 'pivotal', passwordVariable: 'pivotalPASSWORD', usernameVariable: 'pivotalUSERNAME')]){
sh "cf api https://api.run.pivotal.io && cf login -u ${env.USERNAME} -p ${env.PASSWORD}" sh "cf api https://api.run.pivotal.io && cf login -u ${env.pivotalUSERNAME} -p ${env.pivotalPASSWORD}"
sh 'cf push' 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"
}
}
} }
} }
} }