Skip to content

Commit aeb626d

Browse files
committed
inject buildId containing commitId into classifier for CI archive
1 parent 1b11332 commit aeb626d

File tree

5 files changed

+17
-52
lines changed

5 files changed

+17
-52
lines changed

Jenkinsfile

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,9 @@ def runITsOses = ['linux', 'windows']
2626
def runITsJdks = ['7', '8', '11','12']
2727
def runITsMvn = '3.6.0'
2828
def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true
29-
def tests
3029

3130
try {
3231

33-
def osNode = jenkinsEnv.labelForOS(buildOs)
34-
node(jenkinsEnv.nodeSelection(osNode)) {
35-
dir('build') {
36-
stage('Checkout') {
37-
checkout scm
38-
}
39-
40-
def WORK_DIR=pwd()
41-
def MAVEN_GOAL='verify'
42-
43-
stage('Configure deploy') {
44-
if (env.BRANCH_NAME == 'master'){
45-
MAVEN_GOAL='deploy'
46-
}
47-
}
48-
49-
stage('Build / Unit Test') {
50-
String jdkName = jenkinsEnv.jdkFromVersion(buildOs, buildJdk)
51-
String mvnName = jenkinsEnv.mvnFromVersion(buildOs, buildMvn)
52-
withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/.repository", options:[
53-
artifactsPublisher(disabled: false),
54-
junitPublisher(ignoreAttachments: false),
55-
findbugsPublisher(disabled: false),
56-
openTasksPublisher(disabled: false),
57-
dependenciesFingerprintPublisher(),
58-
invokerPublisher(),
59-
pipelineGraphPublisher()
60-
]) {
61-
sh "mvn clean ${MAVEN_GOAL} -B -U -e -fae -V -Dmaven.test.failure.ignore=true"
62-
}
63-
dir ('apache-maven/target') {
64-
sh "mv apache-maven-*-bin.zip apache-maven-dist.zip"
65-
stash includes: 'apache-maven-dist.zip', name: 'dist'
66-
}
67-
}
68-
69-
tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'master']
70-
}
71-
}
72-
7332
Map runITsTasks = [:]
7433
for (String os in runITsOses) {
7534
for (def jdk in runITsJdks) {
@@ -79,23 +38,24 @@ for (String os in runITsOses) {
7938
echo "OS: ${os} JDK: ${jdk} => Label: ${osLabel} JDK: ${jdkName}"
8039

8140
def cmd = [
82-
'mvn',
41+
'mvn', 'clean',
8342
'verify',
8443
'-DskipTests', '-Drat.skip'
8544
]
8645
if (jdk == '7') {
8746
// Java 7u80 has TLS 1.2 disabled by default: need to explicitely enable
8847
cmd += '-Dhttps.protocols=TLSv1.2'
8948
}
49+
cmd += "-DbuildId=${os}-jdk${jdk}"
9050

9151
String stageId = "${os}-jdk${jdk}"
92-
String stageLabel = "Rebuild ${os.capitalize()} Java ${jdk}"
52+
String stageLabel = "${os.capitalize()} Java ${jdk}"
9353
runITsTasks[stageId] = {
9454
node(jenkinsEnv.nodeSelection(osLabel)) {
9555
def WORK_DIR=pwd()
9656
stage("${stageLabel}") {
9757
echo "NODE_NAME = ${env.NODE_NAME}"
98-
checkout tests
58+
checkout scm
9959
withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/.repository", options:[
10060
artifactsPublisher(disabled: false),
10161
junitPublisher(ignoreAttachments: false),
@@ -106,9 +66,13 @@ for (String os in runITsOses) {
10666
pipelineGraphPublisher()
10767
]) {
10868
if (isUnix()) {
109-
sh cmd.join(' ')
69+
String commitId = sh(returnStdout: true, script: 'git rev-parse HEAD')
70+
sh cmd.join(' ') + "-${commitId}"
11071
} else {
111-
bat cmd.join(' ')
72+
String commitId = bat(returnStdout: true, script: 'git rev-parse HEAD').tokenize(' ')[-1].trim()
73+
echo "commitId = ${commitId}"
74+
echo "command = " + cmd.join(' ') + "-${commitId}"
75+
bat cmd.join(' ') + "-${commitId}"
11276
}
11377
}
11478
}

apache-maven/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ under the License.
210210
<fileSet>
211211
<directory>${project.build.directory}</directory>
212212
<includes>
213-
<include>${project.artifactId}-${project.version}-bin.zip</include>
214-
<include>${project.artifactId}-${project.version}-bin.tar.gz</include>
215-
<include>${project.artifactId}-${project.version}-src.zip</include>
216-
<include>${project.artifactId}-${project.version}-src.tar.gz</include>
213+
<include>${project.artifactId}-${project.version}-bin-${buildId}.zip</include>
214+
<include>${project.artifactId}-${project.version}-bin-${buildId}.tar.gz</include>
215+
<include>${project.artifactId}-${project.version}-src-${buildId}.zip</include>
216+
<include>${project.artifactId}-${project.version}-src-${buildId}.tar.gz</include>
217217
</includes>
218218
</fileSet>
219219
</fileSets>

apache-maven/src/main/assembly/bin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ under the License.
1919

2020
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2121
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
22-
<id>bin</id>
22+
<id>bin-${buildId}</id>
2323
<formats>
2424
<format>zip</format>
2525
<format>tar.gz</format>

apache-maven/src/main/assembly/src.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ under the License.
1919

2020
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2121
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
22-
<id>src</id>
22+
<id>src-${buildId}</id>
2323
<formats>
2424
<format>zip</format>
2525
<format>tar.gz</format>

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ under the License.
7676
<maven.site.path>ref/3-LATEST</maven.site.path>
7777
<checkstyle.violation.ignore>None</checkstyle.violation.ignore>
7878
<checkstyle.excludes>**/package-info.java</checkstyle.excludes>
79+
<buildId>${os.name}-jdk${java.version}</buildId>
7980
</properties>
8081

8182
<modules>

0 commit comments

Comments
 (0)