Skip to content

Instantly share code, notes, and snippets.

@sherl0cks
Last active April 24, 2018 20:56
Show Gist options
  • Save sherl0cks/0c1e09d28c05ceffbf755fd02bf4aa9f to your computer and use it in GitHub Desktop.
Save sherl0cks/0c1e09d28c05ceffbf755fd02bf4aa9f to your computer and use it in GitHub Desktop.
pipeline {
agent { label 'jenkins-slave-mvn' }
environment {
// dunno why this is failing
// BASE_NAMESPACE = "${OPENSHIFT_BUILD_NAMESPACE}".reverse().drop(6).reverse()
CI_CD_PROJECT = "ci-cd"
DEV_PROJECT = "dev"
TEST_PROJECT = "test"
SOURCE_CONTEXT_DIR = ""
UBER_JAR_CONTEXT_DIR = "assistant-application/target/"
MVN_COMMAND = "clean deploy"
MVN_SNAPSHOT_DEPLOYMENT_REPOSITORY = "nexus::default::http://nexus:8081/repository/maven-snapshots"
MVN_RELEASE_DEPLOYMENT_REPOSITORY = "nexus::default::http://nexus:8081/repository/maven-releases"
APP_NAME = "spring-boot-cxf" // TODO "${JOB_NAME}".replaceAll(/-?${PROJECT_NAME}-?/, '').replaceAll(/-?pipeline-?/, '')
OCP_API_SERVER = "${OPENSHIFT_API_URL}"
OCP_TOKEN = readFile('/var/run/secrets/kubernetes.io/serviceaccount/token').trim()
}
stages {
stage('Build'){
steps{
// checkout scm is not needed anymore, it's automatic
sh 'mvn clean deploy -DaltDeploymentRepository=${MVN_SNAPSHOT_DEPLOYMENT_REPOSITORY} -q'
}
}
stage('Bake'){
steps{
script{
openshift.withCluster () {
openshift.startBuild( "${APP_NAME} --from-dir=${UBER_JAR_CONTEXT_DIR} --follow" )
}
}
}
}
stage('Deploy: Dev'){
agent { label 'jenkins-slave-ansible'}
steps {
script{
def helper = load 'shared-library.groovy'
helper.applyAnsibleInventory( 'dev' )
timeout(5) { // in minutes
openshift.verbose()
helper.promoteImageWithinCluster( "${APP_NAME}", "${CI_CD_PROJECT}", "${DEV_PROJECT}" )
// the new client is having random failures
helper.verifyDeployment("${APP_NAME}", "${DEV_PROJECT}")
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment