-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathJenkinsfile
109 lines (95 loc) · 2.96 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
#!/usr/bin/env groovy
// 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) { infrapool, sourceVersion, targetVersion, assetDirectory ->
// Any assets from sourceVersion Github release are available in assetDirectory
// Any version number updates from sourceVersion to targetVersion occur here
// Any publishing of targetVersion artifacts occur here
// Anything added to assetDirectory will be attached to the Github Release
//Note: assetDirectory is on the infrapool agent, not the local Jenkins agent.
}
release.copyEnterpriseRelease(params.VERSION_TO_PROMOTE)
return
}
pipeline {
agent { label 'conjur-enterprise-common-agent' }
options {
ansiColor('xterm')
timestamps()
buildDiscarder(logRotator(daysToKeepStr: '30'))
}
triggers {
cron(getDailyCronString())
}
environment {
// Sets the MODE to the specified or autocalculated value as appropriate
MODE = release.canonicalizeMode()
}
stages {
stage('Get InfraPool Agents') {
steps{
script {
infrapool = getInfraPoolAgent.connected(type: "ExecutorV2", quantity: 1, duration: 1)[0]
}
}
}
stage('Validate Changelog') {
steps {
script {
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 {
updateVersion(infrapool, "CHANGELOG.md", "${BUILD_NUMBER}")
}
}
stage('Test workflow') {
steps {
script {
infrapool.agentSh './test_workflow.sh'
}
}
}
stage('Release') {
when {
expression {
MODE == "RELEASE"
}
}
steps {
script {
release(infrapool, { billOfMaterialsDirectory, assetDirectory ->
/* Publish release artifacts to all the appropriate locations
Copy any artifacts to assetDirectory on the infrapool node
to attach them to the Github release.
If your assets are on the infrapool node in the target
directory, use a copy like this:
infrapool.agentSh "cp target/* ${assetDirectory}"
Note That this will fail if there are no assets, add :||
if you want the release to succeed with no assets.
If your assets are in target on the main Jenkins agent, use:
infrapool.agentPut(from: 'target/', to: assetDirectory)
*/
})
}
}
}
}
post {
always {
script {
releaseInfraPoolAgent(".infrapool/release_agents")
}
}
}
}