Define new template for subproject release build 51/17451/1
authorDan Timoney <dtimoney@att.com>
Fri, 6 Oct 2017 13:52:29 +0000 (09:52 -0400)
committerDan Timoney <dtimoney@att.com>
Fri, 6 Oct 2017 13:52:29 +0000 (09:52 -0400)
Define a new template for subproject release builds that does not
update the version tag within the <parent>.  This is needed for
the oparent-odlparent subproject of oparent, whose parent is an
external POM from the OpenDaylight project.

Change-Id: I798b0292f17b6b9d5234f147910488e4bb6ecee2
Issue-ID: CIMAN-99
Signed-off-by: Dan Timoney <dtimoney@att.com>
jjb/global-templates-java.yaml
jjb/include-update-pom-versions-not-parent.sh [new file with mode: 0644]
jjb/oparent/oparent.yaml

index 713ea2f..5255cef 100644 (file)
       - infra-shiplogs:
           maven-version: '{maven-version}'
 
+- job-template:
+    # Job template for Java daily release jobs
+    #
+    # The purpose of this job template is to run
+    #   - change version in all POM files to the release version specified
+    #     in version.properties. This is done using a script instread of
+    #     the mvn version plugin that assumes some specific parent structure
+    #     This version does NOT change the version within the <parent> tag.
+    #   - runs maven clean deploy sonar
+    #
+    # The POM files are required to use the Maven staging plugin so the deploy
+    # does not deploy directly to the release repo.
+    #
+    # Required Variables:
+    #     branch:    git branch (eg. stable/lithium or master)
+    #     pom:       name/location of the pom.xml file relative to the workspace
+    #     pattern:   ant file-path pattern relative to the workspace used to
+    #                trigger the job
+
+    name: '{project-name}-{stream}-{subproject}-release-version3-java-daily'
+
+    project-type: freestyle
+    node: '{build-node}'
+    maven-deploy-properties:
+    properties:
+      - infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+
+    parameters:
+      - infra-parameters:
+          project: '{project}'
+          branch: '{branch}'
+          refspec: 'refs/heads/{branch}'
+          artifacts: '{archive-artifacts}'
+      - maven-exec:
+          maven-version: '{maven-version}'
+
+    scm:
+      - gerrit-trigger-scm:
+          refspec: ''
+          choosing-strategy: 'default'
+          submodule-recursive: '{submodule-recursive}'
+
+    wrappers:
+      - infra-wrappers:
+          build-timeout: '{build-timeout}'
+
+    triggers:
+      # 11 AM UTC
+      - timed: 'H 11 * * *'
+      - gerrit-trigger-release-manually:
+          server: '{server-name}'
+          project: '{project}'
+          branch: '{branch}'
+          files: '{pattern}'
+
+    builders:
+      - provide-maven-settings:
+          global-settings-file: 'global-settings'
+          settings-file: '{mvn-settings}'
+      - maven-install:
+          maven-version: '{maven-version}'
+
+      - inject:
+          properties-file: version.properties
+
+      - shell: !include-raw-escape: include-update-pom-versions-not-parent.sh
+
+      - maven-target:
+          maven-version: '{maven-version}'
+          pom: '{pom}'
+          goals: 'clean deploy sonar:sonar site:site site:stage-deploy
+            -Dsonar.host.url=${{SONAR}} -B
+            -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
+          properties:
+            - '{maven-deploy-properties}'
+          settings: '{mvn-settings}'
+          settings-type: cfp
+          global-settings: 'global-settings'
+          global-settings-type: cfp
+
+    publishers:
+      - infra-shiplogs:
+          maven-version: '{maven-version}'
+
 - job-template:
     # Template for maven site plugin invocation
     #
diff --git a/jjb/include-update-pom-versions-not-parent.sh b/jjb/include-update-pom-versions-not-parent.sh
new file mode 100644 (file)
index 0000000..ace2350
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+## Will update POM in workspace with release version
+
+if [ ! -e version.properties ]; then
+    echo "Missing version.properties"
+    exit 1
+fi
+
+## will setup variable release_version
+source ./version.properties
+
+RELEASE_VERSION=$release_version
+
+echo Changing POM version to $RELEASE_VERSION
+
+## handle POM
+for file in $(find . -name pom.xml); do
+    VERSION=$(xpath -q -e '//project/version/text()' $file)
+    PVERSION=$(xpath -q -e '//project/parent/version/text()' $file)
+    echo before changes VERSION=$VERSION PVERSION=$PVERSION file=$file
+    if [ "$VERSION" != "" ]; then
+        awk -v v=$RELEASE_VERSION '
+            /<version>/ {
+                if (! done) {
+                    sub(/<version>.*</,"<version>" v "<",$0)
+                    done = 1
+                }
+            }
+            { print $0 }
+        ' $file > $file.tmp
+        mv $file.tmp $file
+    fi
+    VERSION=$(xpath -q -e '//project/version/text()' $file)
+    PVERSION=$(xpath -q -e '//project/parent/version/text()' $file)
+    echo after changes VERSION=$VERSION PVERSION=$PVERSION file=$file
+done
+
index 548e927..be4ad0c 100644 (file)
@@ -9,7 +9,7 @@
     jobs:
       - '{project-name}-{stream}-{subproject}-verify-java'
       - '{project-name}-{stream}-{subproject}-merge-java'
-      - '{project-name}-{stream}-{subproject}-release-version2-java-daily'
+      - '{project-name}-{stream}-{subproject}-release-version3-java-daily'
       - '{project-name}-{stream}-verify-java'
       - '{project-name}-{stream}-merge-java'
       - '{project-name}-{stream}-release-version-java-daily-no-sonar'