Skip to content

Instantly share code, notes, and snippets.

@cyrille-leclerc
Last active October 29, 2015 20:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrille-leclerc/b818e8e2d6320793e2a3 to your computer and use it in GitHub Desktop.
Save cyrille-leclerc/b818e8e2d6320793e2a3 to your computer and use it in GitHub Desktop.
Jenkins Workflow code snippet to deploy a java-maven web app to Cloud Foundry runtime using CloudBees Cloud Foundry CLI Plugin
node() {
stage 'BUILD'
git url:'https://github.com/cyrille-leclerc/spring-petclinic.git'
env.PATH = "${tool 'Maven (latest)'}/bin:${env.PATH}"
env.PATH = "${tool 'CloudFoundry CLI 6.9.0-cloudbees-1'}:${env.PATH}"
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'pws-credentials-id',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
stage concurrency: 1, name: 'DEPLOY'
sh '''
# set -x
mvn -Dmaven.test.skip=true package
cf api https://api.run.pivotal.io
cf auth $USERNAME $PASSWORD
cf target -o cleclerc -s development
cf apps
cf push petclinic-clc -p target/petclinic.war
# cf logout should be defined in a 'finally' block
cf logout
'''
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment