-
Notifications
You must be signed in to change notification settings - Fork 30
/
JenkinsfileStageMerge
109 lines (101 loc) · 4.4 KB
/
JenkinsfileStageMerge
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
// Openshift project
OPENSHIFT_NAMESPACE = "continuous-infra"
DOCKER_REPO_URL = '172.30.254.79:5000'
STABLE_LABEL = "stable"
// git commit default
env.ghprbActualCommit = env.ghprbActualCommit ?: 'master'
imageOperations = []
library identifier: "ci-pipeline@master",
retriever: modernSCM([$class: 'GitSCMSource',
remote: "https://github.com/CentOS-PaaS-SIG/ci-pipeline"])
properties([
buildDiscarder(logRotator(artifactNumToKeepStr: '20', numToKeepStr: '20')),
[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/CentOS-PaaS-SIG/contra-env-setup/'],
[$class: 'org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty', triggers:[
[
$class: 'org.jenkinsci.plugins.ghprb.GhprbTrigger',
orgslist: 'CentOS-PaaS-SIG',
cron: 'H/5 * * * *',
triggerPhrase: '.*\\[merge\\].*',
onlyTriggerPhrase: true,
useGitHubHooks: true,
permitAll: false,
autoCloseFailedPullRequests: false,
displayBuildErrorsOnDownstreamBuilds: true,
extensions: [
[
$class: 'org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus',
commitStatusContext: 'Merge PR',
showMatrixStatus: false,
triggeredStatus: 'Starting job...',
startedStatus: 'Merging...',
]
]
]
]]
])
pipeline {
agent {
kubernetes {
cloud 'openshift'
label 'merge-trigger-' + env.ghprbActualCommit
containerTemplate {
name 'jnlp'
args '${computer.jnlpmac} ${computer.name}'
image DOCKER_REPO_URL + '/' + OPENSHIFT_NAMESPACE + '/jenkins-continuous-infra-slave:' + STABLE_LABEL
ttyEnabled false
command ''
}
}
}
stages {
stage("Merge PR") {
steps {
// lock to make sure only one is allowed at anytime
lock('merge-lock') {
script {
// need this for ghprb plugin since it is really
// a post build step and it assumes the build is complete.
currentBuild.result = 'SUCCESS'
}
step([$class: 'GhprbPullRequestMerge', allowMergeWithoutTriggerPhrase: false, deleteOnMerge: false, disallowOwnCode: false, failOnNonMerge: false, mergeComment: ' ', onlyAdminsMerge: false])
}
}
}
stage('Rebuild images') {
parallel {
stage("Rebuild centos7 testing image") {
when {
// Only build if we have related files in changeset or we manually set the parameter for this image
changeset 'test/config/Dockerfiles/contra-env-setup-c7/**'
}
steps {
script {
pipelineUtils.buildStableImage(OPENSHIFT_NAMESPACE, 'contra-env-setup-c7')
imageOperations.add('contra-env-setup-c7')
}
}
}
stage("Rebuild fedora28 testing image") {
when {
// Only build if we have related files in changeset or we manually set the parameter for this image
changeset 'test/config/Dockerfiles/contra-env-setup-f28/**'
}
steps {
script {
pipelineUtils.buildStableImage(OPENSHIFT_NAMESPACE, 'contra-env-setup-f28')
imageOperations.add('contra-env-setup-f28')
}
}
}
}
}
stage("Comment image promotions on PR") {
steps {
script {
pipelineUtils.sendPRCommentforTags(imageOperations)
}
}
}
}
}