Skip to content

Instantly share code, notes, and snippets.

@cyrille-leclerc
Last active November 30, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyrille-leclerc/32c52ea0d5fc92a5b957 to your computer and use it in GitHub Desktop.
Save cyrille-leclerc/32c52ea0d5fc92a5b957 to your computer and use it in GitHub Desktop.
CD Pipeline for Pivotal Cloud Foundry - Jenkinsfile
#!groovy
docker.image('cloudbees/java-build-tools:0.0.5').inside {
checkout scm
def mavenSettingsFile = "${pwd()}/.m2/settings.xml"
stage 'Build Web App'
wrap([$class: 'ConfigFileBuildWrapper',
managedFiles: [[fileId: 'maven-settings-for-gameoflife', targetLocation: "${mavenSettingsFile}"]]]) {
sh "mvn -s ${mavenSettingsFile} -DaltSnapshotDeploymentRepository=cleclerc.artifactoryonline.com::default::https://cleclerc.artifactoryonline.com/cleclerc/libs-snapshot-local clean source:jar deploy"
}
stage 'Deploy Web App On CloudFoundry'
wrap([$class: 'CloudFoundryCliBuildWrapper',
cloudFoundryCliVersion: 'Cloud Foundry CLI (built-in)',
apiEndpoint: 'https://api.hackney.cf-app.com',
skipSslValidation: true,
credentialsId: 'pcf-elastic-runtime-credentials',
organization: 'cloudbees',
space: 'development']) {
sh 'cf push gameoflife-dev -p gameoflife-web/target/gameoflife.war'
}
stash name: 'acceptance-tests', includes: 'gameoflife-acceptance-tests/,gameoflife-web/target/gameoflife.war'
}
stage 'Test Web App with Selenium'
mail body: "Start web browser tests on http://gameoflife-dev.hackney.cf-app.com/ ?", subject: "Start web browser tests on http://gameoflife-dev.hackney.cf-app.com/ ?", to: 'cleclerc@cloudbees.com'
input "Start web browser tests on http://gameoflife-dev.hackney.cf-app.com/ ?"
checkpoint 'Web Browser Tests'
node {
unstash 'acceptance-tests'
// web browser tests are fragile, test up to 3 times
retry(3) {
docker.image('cloudbees/java-build-tools:0.0.5').inside {
def mavenSettingsFile = "${pwd()}/.m2/settings.xml"
wrap([$class: 'ConfigFileBuildWrapper',
managedFiles: [[fileId: 'maven-settings-for-gameoflife', targetLocation: "${mavenSettingsFile}"]]]) {
sh """
# curl http://gameoflife-dev.hackney.cf-app.com/
# curl -v http://localhost:4444/wd/hub
# tree .
cd gameoflife-acceptance-tests
mvn -B -V -s ${mavenSettingsFile} verify -Dwebdriver.driver=remote -Dwebdriver.remote.url=http://localhost:4444/wd/hub -Dwebdriver.base.url=http://gameoflife-dev.hackney.cf-app.com/
"""
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>.m2-repository</localRepository>
<interactiveMode>false</interactiveMode>
<servers>
<server>
<id>cleclerc.artifactoryonline.com</id>
<username>jenkins</username>
<password>********</password>
</server>
</servers>
</settings>
<?xml version="1.0" encoding="UTF-8"?>
<org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject plugin="workflow-multibranch@1.11">
<actions />
<description />
<properties>
<com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider_-FolderCredentialsProperty plugin="cloudbees-folder@5.1">
<domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash">
<entry>
<com.cloudbees.plugins.credentials.domains.Domain plugin="credentials@1.24">
<specifications />
</com.cloudbees.plugins.credentials.domains.Domain>
<java.util.concurrent.CopyOnWriteArrayList />
</entry>
</domainCredentialsMap>
</com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider_-FolderCredentialsProperty>
<com.cloudbees.hudson.plugins.folder.properties.EnvVarsFolderProperty plugin="cloudbees-folders-plus@3.0">
<properties />
</com.cloudbees.hudson.plugins.folder.properties.EnvVarsFolderProperty>
</properties>
<views>
<hudson.model.AllView>
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../../.." />
<name>All</name>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList" />
</hudson.model.AllView>
</views>
<viewsTabBar class="hudson.views.DefaultViewsTabBar" />
<primaryView>All</primaryView>
<healthMetrics>
<com.cloudbees.hudson.plugins.folder.health.WorstChildHealthMetric plugin="cloudbees-folder@5.1" />
<com.cloudbees.hudson.plugins.folder.health.AverageChildHealthMetric plugin="cloudbees-folders-plus@3.0" />
<com.cloudbees.hudson.plugins.folder.health.JobStatusHealthMetric plugin="cloudbees-folders-plus@3.0">
<success>true</success>
<failure>true</failure>
<unstable>true</unstable>
<unbuilt>true</unbuilt>
<countVirginJobs>false</countVirginJobs>
</com.cloudbees.hudson.plugins.folder.health.JobStatusHealthMetric>
<com.cloudbees.hudson.plugins.folder.health.ProjectEnabledHealthMetric plugin="cloudbees-folders-plus@3.0" />
</healthMetrics>
<icon class="com.cloudbees.hudson.plugins.folder.icons.StockFolderIcon" plugin="cloudbees-folder@5.1" />
<orphanedItemStrategy class="com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy" plugin="cloudbees-folder@5.1">
<pruneDeadBranches>true</pruneDeadBranches>
<daysToKeep>0</daysToKeep>
<numToKeep>0</numToKeep>
</orphanedItemStrategy>
<triggers />
<sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api@1.0">
<data>
<jenkins.branch.BranchSource>
<source class="jenkins.plugins.git.GitSCMSource" plugin="git@2.4.0">
<id>0936b450-425e-4c1e-add1-588534959a8f</id>
<remote>https://gitlab.com/cleclerc/game-of-life.git</remote>
<credentialsId />
<includes>*</includes>
<excludes>amazon-ecs-pipeline</excludes>
<ignoreOnPushNotifications>false</ignoreOnPushNotifications>
</source>
<strategy class="jenkins.branch.DefaultBranchPropertyStrategy">
<properties class="empty-list" />
</strategy>
</jenkins.branch.BranchSource>
</data>
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.." />
</sources>
<factory class="org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory">
<owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.." />
</factory>
</org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment