-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
161 lines (142 loc) · 6.91 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/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) { infrapool, 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 {
MODE = release.canonicalizeMode()
}
stages {
stage('Scan for internal URLs') {
steps {
script {
detectInternalUrls()
}
}
}
stage('Get InfraPool ExecutorV2 Agent') {
steps {
script {
// Request InfraPool
INFRAPOOL_EXECUTORV2_AGENT_0 = getInfraPoolAgent.connected(type: "ExecutorV2", quantity: 1, duration: 1)[0]
}
}
}
stage('Get latest upstream dependencies') {
steps {
script {
updatePrivateGoDependencies("${WORKSPACE}/go.mod")
// Copy the vendor directory onto infrapool
INFRAPOOL_EXECUTORV2_AGENT_0.agentPut from: "vendor", to: "${WORKSPACE}"
INFRAPOOL_EXECUTORV2_AGENT_0.agentPut from: "go.*", to: "${WORKSPACE}"
}
}
}
// 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_EXECUTORV2_AGENT_0, "CHANGELOG.md", "${BUILD_NUMBER}")
}
}
stage('Build artifacts') {
steps {
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/build'
}
}
}
stage('Test') {
steps {
withCredentials([
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-tenant_username", variable: 'INFRAPOOL_SHARED_SERVICES_TENANT'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-tenant_address", variable: 'INFRAPOOL_SHARED_SERVICES_DOMAIN'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-client_password", variable: 'INFRAPOOL_SHARED_SERVICES_CLIENT_SECRET'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-client_username", variable: 'INFRAPOOL_SHARED_SERVICES_CLIENT_ID'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_username", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_NAME'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_address", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_ALIAS'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_password", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_REGION'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-account_username", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_ACCOUNT_ID'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-account_password", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_IAM_ROLE')
]){
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test'
}
}
}
post {
always {
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash name: 'output-xml', includes: 'output/*.xml'
}
}
}
}
stage('Run integration tests for P-Cloud and SecretsHub') {
steps {
withCredentials([
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-tenant_username", variable: 'INFRAPOOL_SHARED_SERVICES_TENANT'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-tenant_address", variable: 'INFRAPOOL_SHARED_SERVICES_DOMAIN'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-client_password", variable: 'INFRAPOOL_SHARED_SERVICES_CLIENT_SECRET'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-client_username", variable: 'INFRAPOOL_SHARED_SERVICES_CLIENT_ID'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_username", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_NAME'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_address", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_ALIAS'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-nar_password", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_REGION'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-account_username", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_ACCOUNT_ID'),
conjurSecretCredential(credentialsId: "RnD-Global-Conjur-Ent-Conjur_sh-shared-services-aws-account_password", variable: 'INFRAPOOL_SHARED_SERVICES_AWS_IAM_ROLE')
]){
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/integration-test.sh'
}
}
}
}
stage('Release') {
when {
expression {
MODE == "RELEASE"
}
}
steps {
script {
release(INFRAPOOL_EXECUTORV2_AGENT_0) { billOfMaterialsDirectory, assetDirectory, toolsDirectory ->
// Publish release artifacts to all the appropriate locations
// Copy any artifacts to assetDirectory to attach them to the Github release
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh "cp -r dist/*.zip dist/*_SHA256SUMS ${assetDirectory}"
// Create Go module SBOM
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh """export PATH="${toolsDirectory}/bin:${PATH}" && go-bom --tools "${toolsDirectory}" --go-mod ./go.mod --image "golang" --output "${billOfMaterialsDirectory}/go-mod-bom.json" """
}
}
}
}
}
post {
always {
unstash 'output-xml'
junit 'output/junit.xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'output/coverage.xml', conditionalCoverageTargets: '30, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
codacy action: 'reportCoverage', filePath: "output/coverage.xml"
releaseInfraPoolAgent(".infrapool/release_agents")
}
}
}