mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
deploying to multiple cf environments in pivotal cloud
This commit is contained in:
parent
7cc050a902
commit
358fce454c
2 changed files with 38 additions and 27 deletions
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
|
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue