-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
110 lines (95 loc) · 3.07 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
#!/usr/bin/env groovy
@Library("product-pipelines-shared-library") _
pipeline {
agent { label 'conjur-enterprise-common-agent' }
options {
timestamps()
buildDiscarder(logRotator(daysToKeepStr: '30'))
}
triggers {
cron(getDailyCronString())
}
stages {
stage('Scan for internal URLs') {
steps {
script {
detectInternalUrls()
}
}
}
stage('Get InfraPool ExecutorV2 Agent') {
steps {
script {
// Request ExecutorV2 agents for 1 hour(s)
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}"
}
}
}
stage('Validate') {
parallel {
stage('Changelog') {
steps {
parseChangelog(INFRAPOOL_EXECUTORV2_AGENT_0)
}
}
}
}
stage('Run unit tests') {
steps {
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test.sh'
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash name: 'output-xml', includes: 'output/*.xml'
unstash 'output-xml'
junit 'output/junit.xml'
cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'output/coverage.xml', conditionalCoverageTargets: '30, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh 'cp output/c.out .'
codacy action: 'reportCoverage', filePath: "output/coverage.xml"
}
}
}
stage('Build Release Artifacts') {
when {
not { buildingTag() }
}
steps {
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './build.sh --snapshot'
INFRAPOOL_EXECUTORV2_AGENT_0.agentArchiveArtifacts artifacts: 'dist/goreleaser/'
}
}
}
stage('Build Release Artifacts and Create Pre Release') {
// Only run this stage when triggered by a tag
when { buildingTag() }
steps {
script {
INFRAPOOL_EXECUTORV2_AGENT_0.agentDir('./pristine-checkout') {
// Go releaser requires a pristine checkout
checkout scm
// Copy the checkout content onto infrapool
INFRAPOOL_EXECUTORV2_AGENT_0.agentPut from: "./", to: "."
// Create draft release
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh 'summon --yaml "GITHUB_TOKEN: !var github/users/conjur-jenkins/api-token" ./build.sh'
}
}
}
}
}
post {
always {
script {
releaseInfraPoolAgent(".infrapool/release_agents")
}
}
}
}