This repository has been archived by the owner on Mar 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-ci
113 lines (107 loc) · 3.42 KB
/
Jenkinsfile-ci
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* CI Stage Pipeline Trigger
*
* This is a declarative pipeline for the CI stage pipeline
* that includes the building of a new cvengine image based
* on a new GitHub PR
*
*/
// Openshift project
openshiftProject = "continuous-infra"
DOCKER_REPO_URL = '172.30.254.79:5000'
// Defaults for SCM operations
env.ghprbGhRepository = env.ghprbGhRepository ?: 'CentOS-PaaS-SIG/cvengine'
env.ghprbActualCommit = env.ghprbActualCommit ?: 'master'
// If this PR does not include an image change, then use this tag
STABLE_LABEL = "stable"
// Initialize
tagMap = [:]
tagMap['jenkins-continuous-infra-slave'] = STABLE_LABEL
tagMap['cvengine'] = STABLE_LABEL
library identifier: "ci-pipeline@master",
retriever: modernSCM([$class: 'GitSCMSource',
remote: "https://github.com/CentOS-Paas-SIG/ci-pipeline"])
pipeline {
agent {
kubernetes {
cloud 'openshift'
label 'cvengine-ci-' + env.ghprbActualCommit
containerTemplate {
name 'jnlp'
args '${computer.jnlpmac} ${computer.name}'
image DOCKER_REPO_URL + '/' + openshiftProject + '/jenkins-continuous-infra-slave:' + STABLE_LABEL
ttyEnabled false
command ''
}
}
}
stages {
stage("Get Changelog") {
steps {
node('master') {
script {
echo "PR number is: ${env.ghprbPullId}"
env.changeLogStr = pipelineUtils.getChangeLogFromCurrentBuild()
echo env.changeLogStr
}
writeFile file: 'changelog.txt', text: env.changeLogStr
archiveArtifacts allowEmptyArchive: true, artifacts: 'changelog.txt'
}
}
}
stage("Setup Container Templates") {
steps {
script {
pipelineUtils.setupContainerTemplates(openshiftProject)
}
}
}
stage("cvengine image build") {
steps {
script {
tagMap['cvengine'] = pipelineUtils.buildImage(openshiftProject, "cvengine")
}
}
}
stage("Image Tag Report") {
steps {
script {
// Use tags derived from above image builds
//
pipelineUtils.printLabelMap(tagMap)
}
}
}
stage("Run Stage Jobs") {
failFast true
parallel {
stage("cvengine job") {
steps {
sleep 30
build job: 'container-validation',
parameters: [
string(name: 'CVENGINE_TAG', value: tagMap['cvengine'])
],
wait: true
}
}
}
}
}
post {
always {
script {
String prMsg = ""
if (env.ghprbActualCommit != null && env.ghprbActualCommit != "master") {
prMsg = "(PR #${env.ghprbPullId} ${env.ghprbPullAuthorLogin})"
}
}
}
success {
echo "yay!"
}
failure {
error "build failed!"
}
}
}