-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
57 lines (49 loc) · 2.38 KB
/
Jenkinsfile
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
// Edit your app's name below
def APP_NAME = 'prime-web'
// prime-web-build-angular-app-build
def CHAINED_ANGULAR_BUILD = 'angular-builder-' + APP_NAME
// Edit your environment TAG names below
def TAG_NAMES = ['dev', 'test', 'prod']
def TAG_NAMES_BACKUP = ['devbackup', 'testbackup', 'prodbackup']
// You shouldn't have to edit these if you're following the conventions
def NGINX_BUILD_CONFIG = 'nginx-runtime-' + APP_NAME
def BUILD_CONFIG = APP_NAME + '-build'
def IMAGESTREAM_NAME = APP_NAME
node {
stage('build nginx runtime') {
echo "Building: " + NGINX_BUILD_CONFIG
openshiftBuild bldCfg: NGINX_BUILD_CONFIG, showBuildLogs: 'true'
}
stage('build chained app ' + CHAINED_ANGULAR_BUILD) {
echo "Building Chanined Angular Build: " + CHAINED_ANGULAR_BUILD
openshiftBuild bldCfg: CHAINED_ANGULAR_BUILD, showBuildLogs: 'true'
}
stage('build ' + BUILD_CONFIG) {
echo "Building: " + BUILD_CONFIG
openshiftBuild bldCfg: BUILD_CONFIG, showBuildLogs: 'true'
IMAGE_HASH = sh (
script: """oc get istag ${IMAGESTREAM_NAME}:latest -o template --template=\"{{.image.dockerImageReference}}\"|awk -F \":\" \'{print \$3}\'""",
returnStdout: true).trim()
echo ">> IMAGE_HASH: $IMAGE_HASH"
}
stage('deploy-' + TAG_NAMES[0]) {
echo "Deploy to " + TAG_NAMES[0] + " " + IMAGESTREAM_NAME + ":" + "${IMAGE_HASH}"
openshiftTag destStream: IMAGESTREAM_NAME, verbose: 'true', destTag: TAG_NAMES[0], srcStream: IMAGESTREAM_NAME, srcTag: "${IMAGE_HASH}"
}
}
node {
stage('deploy-' + TAG_NAMES[1]) {
input "Deploy to " + TAG_NAMES[1] + "?"
echo "Deploy to " + TAG_NAMES[1] + " " + IMAGESTREAM_NAME + ":" + "${IMAGE_HASH}"
openshiftTag destStream: IMAGESTREAM_NAME, verbose: 'true', destTag: TAG_NAMES_BACKUP[1], srcStream: IMAGESTREAM_NAME, srcTag: TAG_NAMES[1]
openshiftTag destStream: IMAGESTREAM_NAME, verbose: 'true', destTag: TAG_NAMES[1], srcStream: IMAGESTREAM_NAME, srcTag: "${IMAGE_HASH}"
}
}
node {
stage('deploy-' + TAG_NAMES[2]) {
input "Deploy to " + TAG_NAMES[2] + "?"
echo "Deploy to " + TAG_NAMES[2] + " " + IMAGESTREAM_NAME + ":" + "${IMAGE_HASH}"
openshiftTag destStream: IMAGESTREAM_NAME, verbose: 'true', destTag: TAG_NAMES_BACKUP[2], srcStream: IMAGESTREAM_NAME, srcTag: TAG_NAMES[2]
openshiftTag destStream: IMAGESTREAM_NAME, verbose: 'true', destTag: TAG_NAMES[2], srcStream: IMAGESTREAM_NAME, srcTag: "${IMAGE_HASH}"
}
}