You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2019/10/20 12:14:05 UTC

[maven] 11/13: add Git commit id to buildId

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch reproducible
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 91a0a9ca2570498a29235e240c0575d02d0e71c3
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Tue Sep 24 23:03:17 2019 +0200

    add Git commit id to buildId
---
 Jenkinsfile | 36 ++++++++++--------------------------
 pom.xml     |  1 +
 2 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 023179b..dfc49a3 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -26,30 +26,9 @@ def runITsOses = ['linux', 'windows']
 def runITsJdks = ['7', '8', '11','12']
 def runITsMvn = '3.6.0'
 def runITscommand = "mvn clean install -Prun-its,embedded -B -U -V" // -DmavenDistro=... -Dmaven.test.failure.ignore=true
-def tests
 
 try {
 
-def osNode = jenkinsEnv.labelForOS(buildOs) 
-node(jenkinsEnv.nodeSelection(osNode)) {
-    dir('build') {
-        stage('Checkout') {
-            checkout scm
-        }
-
-        def WORK_DIR=pwd()
-        def MAVEN_GOAL='verify'
-
-        stage('Configure deploy') {
-           if (env.BRANCH_NAME == 'master'){
-               MAVEN_GOAL='deploy'
-           }
-        }
-
-        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']
-    }
-}
-
 Map runITsTasks = [:]
 for (String os in runITsOses) {
     for (def jdk in runITsJdks) {
@@ -61,21 +40,22 @@ for (String os in runITsOses) {
         def cmd = [
           'mvn', 'clean',
           'verify',
-          '-DskipTests', '-Drat.skip', "-DbuildId=${os}-jdk${jdk}"
+          '-DskipTests', '-Drat.skip'
         ]
         if (jdk == '7') {
           // Java 7u80 has TLS 1.2 disabled by default: need to explicitely enable
           cmd += '-Dhttps.protocols=TLSv1.2'
         }
+        cmd += "-DbuildId=${os}-jdk${jdk}"
 
         String stageId = "${os}-jdk${jdk}"
-        String stageLabel = "Rebuild ${os.capitalize()} Java ${jdk}"
+        String stageLabel = "${os.capitalize()} Java ${jdk}"
         runITsTasks[stageId] = {
             node(jenkinsEnv.nodeSelection(osLabel)) {
                 def WORK_DIR=pwd()
                 stage("${stageLabel}") {
                     echo "NODE_NAME = ${env.NODE_NAME}"
-                    checkout tests
+                    checkout scm
                     withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/.repository", options:[
                         artifactsPublisher(disabled: false),
                         junitPublisher(ignoreAttachments: false),
@@ -86,9 +66,13 @@ for (String os in runITsOses) {
                         pipelineGraphPublisher()
                     ]) {
                       if (isUnix()) {
-                        sh cmd.join(' ')
+                        String commitId = sh(returnStdout: true, script: 'git rev-parse HEAD')
+                        sh cmd.join(' ') + "-${commitId}"
                       } else {
-                        bat cmd.join(' ')
+                        String commitId = bat(returnStdout: true, script: 'git rev-parse HEAD').tokenize(' ')[-1].trim()
+                        echo "commitId = ${commitId}"
+                        echo "command = " + cmd.join(' ') + "-${commitId}"
+                        bat cmd.join(' ') + "-${commitId}"
                       }
                     }
                 }
diff --git a/pom.xml b/pom.xml
index 597953f..2db3f5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,6 +77,7 @@ under the License.
     <checkstyle.violation.ignore>None</checkstyle.violation.ignore>
     <checkstyle.excludes>**/package-info.java</checkstyle.excludes>
     <source-date-epoch>1569085893</source-date-epoch>
+    <buildId>${os.name}-jdk${java.version}</buildId>
   </properties>
 
   <modules>