forked from ExchangeBC/devex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.master
78 lines (73 loc) · 3.46 KB
/
Jenkinsfile.master
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//define functions
@NonCPS
def getChangeString() {
MAX_MSG_LEN = 512
def changeString = ""
def changeLogSets = currentBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
truncated_msg = entry.msg.take(MAX_MSG_LEN)
changeString += " - ${truncated_msg} [${entry.author}]\n"
}
}
if (!changeString) {
changeString = "No changes"
}
return changeString
}
// pipeline
node('maven') {
stage('checkout') {
echo "checking out source"
echo "Build: ${BUILD_ID}"
checkout scm
}
//stage('code quality check') {
// SONARQUBE_PWD = sh (
// script: 'oc env dc/sonarqube --list | awk -F "=" \'/SONARQUBE_ADMINPW/{print $2}\'',
// returnStdout: true).trim()
// //echo "SONARQUBE_PWD: ${SONARQUBE_PWD}"
// SONARQUBE_URL = sh (
// script: 'oc get routes -o wide --no-headers | awk \'/sonarqube/{ print match($0,/edge/) ? "https://"$2 : "http://"$2 }\'',
// returnStdout: true).trim()
// echo "SONARQUBE_URL: ${SONARQUBE_URL}"
// dir('sonar-runner') {
// sh returnStdout: true, script: "./gradlew sonarqube -Dsonar.host.url=${SONARQUBE_URL} -Dsonar.verbose=true --stacktrace --info -Dsonar.sources=.."
// }
//}
stage('build') {
echo "Building..."
openshiftBuild bldCfg: 'devxp', showBuildLogs: 'true'
openshiftVerifyBuild bldCfg: 'devxp', checkForTriggeredDeployments: 'false', namespace: 'devex-platform-tools', verbose: 'false'
echo ">>>> Build Complete"
openshiftTag destStream: 'devxp', verbose: 'true', destTag: 'M.$BUILD_ID', srcStream: 'devxp', srcTag: 'latest'
}
}
stage('deploy-test') {
timeout(time: 2, unit: 'DAYS') {
input message: "Deploy to test?", submitter: 'scchapma-admin,mark-a-wilson-view,paulroberts68-view,agehlers-admin,ccoldwell-admin'
}
node('master'){
openshiftTag destStream: 'devxp', verbose: 'true', destTag: 'test', srcStream: 'devxp', srcTag: 'M.$BUILD_ID'
openshiftVerifyDeployment depCfg: 'platform-test', namespace: 'devex-platform-test', replicaCount: 1, verbose: 'false', verifyReplicaCount: 'false'
echo ">>>> Deployment Complete"
subject: "FYI: Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) deployed to test",
body: "Changes:\n" + getChangeString() + "\n\nSee ${env.BUILD_URL} for details. ");
}
}
stage('deploy-prod') {
timeout(time: 3, unit: 'DAYS') {
input message: "Deploy to prod?", submitter: 'scchapma-admin,mark-a-wilson-view,paulroberts68-view,agehlers-admin,ccoldwell-admin'
}
node('master'){
openshiftTag destStream: 'devxp', verbose: 'true', destTag: 'prod', srcStream: 'devxp', srcTag: 'M.$BUILD_ID'
openshiftVerifyDeployment depCfg: 'platform-prod', namespace: 'devex-platform-prod', replicaCount: 1, verbose: 'false', verifyReplicaCount: 'false'
echo ">>>> Deployment Complete"
subject: "FYI: Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) deployed to production",
body: "Changes:\n" + getChangeString() + "\n\nSee ${env.BUILD_URL} for details. ");
}
}