Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
93 lines (87 loc) · 2.91 KB
/
Copy pathJenkinsfile
File metadata and controls
93 lines (87 loc) · 2.91 KB
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
#!/usr/bin/env groovy
// Do not rebuild daily if not on the principal branch (e.g. not on PR, not on other branches, not on tags)
final String cronPattern = env.BRANCH_IS_PRIMARY ? '@daily' : ''
// Docker is required for Integration Tests.
final String agentLabel = infra.isInfra() ? 'linux-amd64-docker' : 'docker && linux-amd64 && spot'
pipeline {
agent {
label agentLabel
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
skipStagesAfterUnstable()
timestamps()
}
triggers {
cron(cronPattern)
}
stages {
stage('Build') {
environment {
JAVA_HOME = '/opt/jdk-25/'
}
steps {
script {
if (!env.BRANCH_IS_PRIMARY) {
sh '''
git remote -vvv
git fetch origin main
'''
}
infra.withArtifactCachingProxy() {
def OPTS = env.MAVEN_SETTINGS ? "-s ${MAVEN_SETTINGS}" : ''
// TODO enable spotless on infra when we understand why fetching origin/main is not enough
OPTS += env.TAG_NAME || infra.isInfra() ? ' -Dspotless.check.skip=true' : ''
withEnv(["OPTS=${OPTS}"]) {
sh '''
./mvnw -V \
--no-transfer-progress \
${OPTS} \
clean \
verify \
checkstyle:checkstyle \
spotbugs:spotbugs \
-Dmaven.test.failure.ignore \
-Dcheckstyle.failOnViolation=false \
-Dspotbugs.failOnError=false
'''
}
}
}
}
post {
always {
discoverGitReferenceBuild referenceJob: 'main'
junit (
allowEmptyResults: false,
testResults: '**/target/surefire-reports/*.xml, **/target/failsafe-reports/*.xml'
)
recordCoverage(tools: [[parser: 'JACOCO', pattern: '**/target/site/**/jacoco.xml', mergeToOneReport: true]], sourceCodeRetention: 'MODIFIED')
recordIssues enabledForFailure: true,
tools: [mavenConsole(), java(), javaDoc()]
recordIssues enabledForFailure: true,
tool: checkStyle(),
qualityGates: [[ threshold: 1, type: 'NEW', unstable: true ]]
recordIssues enabledForFailure: true,
tool: spotBugs(),
qualityGates: [[ threshold: 1, type: 'NEW', unstable: true ]]
}
success {
stash name: 'binary', includes: 'war/target/plugin-health-scoring.jar'
}
}
}
stage('Docker image') {
steps {
buildDockerAndPublishImage('plugin-health-scoring', [
dockerfile: 'war/src/main/docker/Dockerfile',
unstash: 'binary',
disablePublication: !infra.isInfra(),
publishToPrivateAzureRegistry: true,
targetplatforms: 'linux/arm64',
automaticSemanticVersioning: false,
])
}
}
}
}