forked from openshift/contra-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsfileExample
111 lines (98 loc) · 5.92 KB
/
JenkinsfileExample
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
properties(
[
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '100', daysToKeepStr: '90', numToKeepStr: '100')),
[$class: 'JobPropertyImpl', throttle: [count: 150, durationName: 'hour', userBoost: false]],
parameters(
[
string(name: 'PROVIDED_KOJI_TASKID',
defaultValue: '',
description: 'Give an integer only task id to use those artifacts and bypass the rpm build stage (example 123456)'),
string(name: 'ghprbActualCommit',
defaultValue: 'master',
description: 'The GitHub pull request commit'),
string(name: 'ghprbGhRepository',
defaultValue: 'openshift/contra-lib',
description: 'The repo the PR is against'),
string(name: 'sha1',
defaultValue: '',
description: ''),
string(name: 'ghprbPullId',
defaultValue: '',
description: 'Pull Request Number'),
string(name: 'ghprbPullAuthorLogin',
defaultValue: '',
description: 'Pull Request Author username'),
string(name: 'SLAVE_TAG',
defaultValue: 'stable',
description: 'Tag for slave image'),
string(name: 'RPMBUILD_TAG',
defaultValue: 'stable',
description: 'Tag for rpmbuild image'),
string(name: 'CLOUD_IMAGE_COMPOSE_TAG',
defaultValue: 'stable',
description: 'Tag for cloud-image-compose image'),
string(name: 'SINGLEHOST_TEST_TAG',
defaultValue: 'stable',
description: 'Tag for singlehost test image'),
string(name: 'DOCKER_REPO_URL',
defaultValue: 'docker-registry.default.svc:5000',
description: 'Docker repo url for Openshift instance'),
string(name: 'OPENSHIFT_NAMESPACE',
defaultValue: 'continuous-infra',
description: 'Project namespace for Openshift operations'),
string(name: 'OPENSHIFT_SERVICE_ACCOUNT',
defaultValue: 'jenkins',
description: 'Service Account for Openshift operations'),
string(name: 'CI_MESSAGE',
defaultValue: CANNED_CI_MESSAGE,
description: 'CI_MESSAGE')
]
),
]
)
libraries = ['cico-pipeline' : ['master', 'https://github.com/CentOS/cico-pipeline-library.git'],
'ci-pipeline' : ['master', 'https://github.com/CentOS-PaaS-SIG/ci-pipeline.git']]
libraries.each { name, repo ->
library identifier: "${name}@${repo[0]}",
retriever: modernSCM([$class: 'GitSCMSource',
remote: repo[1]])
}
// Check out PR's version of library
library identifier: "upstream-fedora-pipeline@${env.ghprbActualCommit}",
retriever: modernSCM([$class: 'GitSCMSource',
remote: "https://github.com/${env.ghprbGhRepository}",
traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'],
[$class: 'RefSpecsSCMSourceTrait',
templates: [[value: '+refs/heads/*:refs/remotes/@{remote}/*'],
[value: '+refs/pull/*:refs/remotes/origin/pr/*']]]]])
containersWithProps = ['rpmbuild': [tag: env.RPMBUILD_TAG],
'cloud-image-compose': [tag: env.CLOUD_IMAGE_COMPOSE_TAG],
'single-host-test': [tag: SINGLEHOST_TEST_TAG]
]
deployOpenShiftTemplate(containersWithProps: containersWithProps, docker_repo_url: env.DOCKER_REPO_URL) {
ciPipeline(buildPrefix: 'contra-build-pipeline', package_name: 'vim') {
stage('koji-build') {
handlePipelineStep(beforeRunMsg: [:], afterRunMsg: [:], failedRunMsg: [:]) {
executeInContainer(containerName: 'rpmbuild', containerScript: '/tmp/koji_build_pr.sh',
stageVars: [package_name: 'vim'])
}
}
stage('repoquery') {
handlePipelineStep {
executeInContainer(containerName: 'rpmbuild', containerScript: '/tmp/repoquery.sh')
}
}
stage('cloud-image-compose') {
stageVars = [repo: 'vim', branch: 'rawhide', fed_branch: 'f28']
handlePipelineStep(beforeRunMsg: [:], afterRunMsg: [:], failedRunMsg: [:]) {
executeInContainer(containerName: 'cloud-image-compose', containerScript: '/tmp/virt-customize.sh',
stageVars: stageVars)
}
}
stage('package-tests') {
handlePipelineStep(beforeRunMsg: [:], afterRunMsg: [:], failedRunMsg: [:]) {
executeInContainer(containerName: 'single-host-test', containerScript: '/tmp/package-test.sh')
}
}
}
}