-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile
145 lines (126 loc) · 3.64 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env groovy
@Library("product-pipelines-shared-library") _
// Automated release, promotion and dependencies
properties([
// Include the automated release parameters for the build
release.addParams(),
// Dependencies of the project that should trigger builds
dependencies([])
])
// Performs release promotion. No other stages will be run
if (params.MODE == "PROMOTE") {
release.promote(params.VERSION_TO_PROMOTE) { sourceVersion, targetVersion, assetDirectory ->
}
// Copy Github Enterprise release to Github
release.copyEnterpriseRelease(params.VERSION_TO_PROMOTE)
return
}
pipeline {
agent { label 'conjur-enterprise-common-agent' }
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '30'))
}
triggers {
cron(getDailyCronString())
}
environment {
// Sets the MODE to the specified or autocalculated value as appropriate
MODE = release.canonicalizeMode()
}
stages {
// Aborts any builds triggered by another project that wouldn't include any changes
stage ("Skip build if triggering job didn't create a release") {
when {
expression {
MODE == "SKIP"
}
}
steps {
script {
currentBuild.result = 'ABORTED'
error("Aborting build because this build was triggered from upstream, but no release was built")
}
}
}
stage('Scan for internal URLs') {
steps {
script {
detectInternalUrls()
}
}
}
stage('Get InfraPool ExecutorV2 Agent') {
steps {
script {
// Request ExecutorV2 agents for 1 hour(s)
INFRAPOOL_EXECUTORV2_AGENTS = getInfraPoolAgent(type: "ExecutorV2", quantity: 1, duration: 1)
INFRAPOOL_EXECUTORV2_AGENT_0 = INFRAPOOL_EXECUTORV2_AGENTS[0]
infrapool = infraPoolConnect(INFRAPOOL_EXECUTORV2_AGENT_0, {})
}
}
}
stage('Validate') {
parallel {
stage('Changelog') {
steps { parseChangelog(infrapool) }
}
}
}
// Generates a VERSION file based on the current build number and latest version in CHANGELOG.md
stage('Validate Changelog and set version') {
steps {
script {
updateVersion(infrapool, "CHANGELOG.md", "${BUILD_NUMBER}")
}
}
}
stage('Prepare build environment') {
steps {
script {
infrapool.agentSh '''
# make sure the build env is up to date
make -C docker
TAG=`cat docker/tag`
if [ -z `docker images -q $TAG` ]; then
# the image is not present, so pull or build
docker pull $TAG || make -C docker rebuild
fi
'''
}
}
}
stage('Build and test package') {
steps {
script {
infrapool.agentSh "summon -e pipeline ./build.sh"
infrapool.agentStash name: 'test-results', includes: '*.xml'
unstash 'test-results'
junit 'TestResults.xml'
infrapool.agentArchiveArtifacts artifacts: 'bin/*', fingerprint: true
}
}
}
stage('Release') {
when {
expression {
MODE == "RELEASE"
}
}
steps {
script {
release(infrapool) { billOfMaterialsDirectory, assetDirectory, toolsDirectory ->
// Publish release artifacts to all the appropriate locations
// Copy any artifacts to assetDirectory to attach them to the Github release
infrapool.agentSh "cp -r bin/* ${assetDirectory}"
}
}
}
}
}
post {
always {
releaseInfraPoolAgent(".infrapool/release_agents")
}
}
}