Another Jenkinsfile update.

This commit is contained in:
Andrew Pitt 2020-01-06 14:11:18 -05:00
parent 2eeed5fbd4
commit 322469f749

64
Jenkinsfile vendored
View file

@ -22,8 +22,10 @@ pipeline {
echo "Checkout source."
git url: "${gitSourceUrl}", branch: "${gitSourceRef}"
echo "Read POM info."
pom = readMavenPom file: 'pom.xml'
projectVersion = pom.version
script {
pom = readMavenPom file: 'pom.xml'
projectVersion = pom.version
}
}
}
stage('Build JAR') {
@ -42,11 +44,13 @@ pipeline {
}
stage('Build Image') {
steps {
echo "Build container image."
openshift.withCluster() {
script {
echo "Build container image."
openshift.withCluster() {
openshift.withProject('cicd') {
sh "oc start-build ${appName}-s2i-build --from-file=target/app.jar -n cicd --follow"
sh "oc start-build ${appName}-s2i-build --from-file=target/app.jar -n cicd --follow"
}
}
}
}
}
@ -66,42 +70,52 @@ pipeline {
}
stage('Deploy DEV') {
steps {
echo "Deploy to DEV."
openshift.withCluster() {
openshift.withProject("${appName}-dev") {
echo "Rolling out to DEV."
def dc = openshift.selector('dc', "${appName}")
dc.rollout().latest()
dc.rollout().status()
script {
echo "Deploy to DEV."
openshift.withCluster() {
openshift.withProject("${appName}-dev") {
echo "Rolling out to DEV."
def dc = openshift.selector('dc', "${appName}")
dc.rollout().latest()
dc.rollout().status()
}
}
}
}
}
stage('Integration Tests') {
echo "Running Integration tests..."
sh "mvn verify -Pfailsafe"
steps {
echo "Running Integration tests..."
sh "mvn verify -Pfailsafe"
}
}
stage('Tag UAT') {
agent {
label 'jenkins-slave-skopeo'
}
script {
openshift.withCluster() {
withCredentials([usernamePassword(credentialsId: "${openshift.project()}-quay-creds-secret", usernameVariable: "QUAY_USERNAME", passwordVariable: "QUAY_PASSWORD")]) {
sh "skopeo copy docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:dev docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:uat --src-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --dest-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --src-tls-verify=false --dest-tls-verify=false"
steps {
script {
openshift.withCluster() {
withCredentials([usernamePassword(credentialsId: "${openshift.project()}-quay-creds-secret", usernameVariable: "QUAY_USERNAME", passwordVariable: "QUAY_PASSWORD")]) {
sh "skopeo copy docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:dev docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:uat --src-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --dest-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --src-tls-verify=false --dest-tls-verify=false"
}
}
}
}
}
stage('Deploy UAT') {
echo "Deploy to UAT."
openshift.withCluster() {
openshift.withProject("${appName}-uat") {
echo "Rolling out to UAT."
def dc = openshift.selector('dc', "${appName}")
dc.rollout().latest()
dc.rollout().status()
steps {
script {
echo "Deploy to UAT."
openshift.withCluster() {
openshift.withProject("${appName}-uat") {
echo "Rolling out to UAT."
def dc = openshift.selector('dc', "${appName}")
dc.rollout().latest()
dc.rollout().status()
}
}
}
}
}
}