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

30
Jenkinsfile vendored
View file

@ -4,7 +4,7 @@ pipeline {
stage('Build') {
agent {
docker {
image 'maven:3.5.0'
image 'maven:3.3.0'
args '--network=pipelinedeveloper_default'
}
}
@ -15,25 +15,17 @@ pipeline {
}
}
}
stage('Build container') {
agent any
stage('Deploy') {
agent {
docker {
image 'liatrio/cf-cli'
}
}
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'
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'
}
}
}
}

View file

@ -1,3 +1,4 @@
#!groovy
pipeline {
agent none
stages {
@ -11,20 +12,38 @@ 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"
}
}
}