Merge "Extract version number passed set '{java-version}'"
authorAnil Belur <abelur@linuxfoundation.org>
Wed, 20 Mar 2019 21:50:01 +0000 (21:50 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Wed, 20 Mar 2019 21:50:01 +0000 (21:50 +0000)
15 files changed:
.jjb-test/lf-macros/lf-maven-central-minimal.yaml
.jjb-test/lf-maven-jobs/lf-maven-versions-plugin.yaml [new file with mode: 0644]
docs/jjb/lf-ci-jobs.rst
docs/jjb/lf-macros.rst
docs/jjb/lf-maven-jobs.rst
jenkins-init-scripts/README
jenkins-init-scripts/create-jenkins-user.sh
jenkins-init-scripts/init.sh
jenkins-init-scripts/package-listing.sh
jjb/lf-ci-jobs.yaml
jjb/lf-maven-jobs.yaml
releasenotes/notes/fix-lf-maven-central-macro-docs-ad43756dcd551c30.yaml [new file with mode: 0644]
releasenotes/notes/optimize-jjb-deploy-regex-5ecc4287ecbc3317.yaml [new file with mode: 0644]
releasenotes/notes/relocatable-init-scripts-3b1c5387fd723904.yaml [new file with mode: 0644]
releasenotes/notes/set-version-condition-dfdbd31461c99e5d.yaml [new file with mode: 0644]

index 5fb58b0..2a2f691 100644 (file)
@@ -7,6 +7,8 @@
     #####################
 
     mvn-central: true
+    mvn-global-settings: ''
+    mvn-settings: ''
     ossrh-profile-id: ''
 
     #####################
@@ -16,4 +18,6 @@
     builders:
       - lf-maven-central:
           mvn-central: '{mvn-central}'
+          mvn-global-settings: '{mvn-global-settings}'
+          mvn-settings: '{mvn-settings}'
           ossrh-profile-id: '{ossrh-profile-id}'
diff --git a/.jjb-test/lf-maven-jobs/lf-maven-versions-plugin.yaml b/.jjb-test/lf-maven-jobs/lf-maven-versions-plugin.yaml
new file mode 100644 (file)
index 0000000..147bc9b
--- /dev/null
@@ -0,0 +1,14 @@
+---
+- project:
+    name: gerrit-maven-versions-plugin-jobs
+    jobs:
+      - gerrit-maven-stage:
+          maven-versions-plugin: true
+          maven-versions-plugin-set-version: 2.0.0
+          mvn-pom: location/pom.xml
+
+    project-name: gerrit-maven-versions-plugin
+    staging-profile-id: uuddlrlrba
+    mvn-settings: gerrit-maven-project-settings
+    mvn-snapshot-id: fakeproject-snapshots
+    nexus-snapshot-repo: fakeproject-snapshots
index a6d67c2..79c0929 100644 (file)
@@ -369,6 +369,18 @@ This job checks out the current code review patch and then runs a
 
     .. note::
 
+       The JJB Deploy Job is configured to trigger only if the Gerrit comment
+       starts with the `jjb-deploy` keyword.
+
+       Example of a valid command in Gerrit comment that triggers the job:
+
+       ``jjb-deploy builder-jjb-*``
+
+       Example of a invalid command in Gerrit comment that would _not_ trigger
+       the job:
+
+       ``Update the job. jjb-deploy builder-jjb-*``
+
        JOB_NAME can include the * wildcard character to push multiple jobs
        matching the pattern. For example ``jjb-deploy builder-jjb-*`` will push
        all builder-jjb-* jobs to the sandbox system.
index 1d7a97b..94fcb1c 100644 (file)
@@ -180,6 +180,10 @@ repository which is to upload to OSSRH.
 :Required parameters:
 
     :mvn-central: Whether or not to upload to mvn-central. (true|false)
+    :mvn-global-settings: The name of the Maven global settings to use for
+        Maven configuration. (default: global-settings)
+    :mvn-settings: The name of settings file containing credentials for the
+        project.
     :ossrh-profile-id: Nexus staging profile ID as provided by OSSRH.
 
 .. literalinclude:: ../../.jjb-test/lf-macros/lf-maven-central-minimal.yaml
index aca0f5f..6097669 100644 (file)
@@ -61,11 +61,30 @@ lf-maven-deploy
 
 Calls the maven deploy script to push artifacts to Nexus.
 
+lf-maven-versions-plugin
+------------------------
+
+Conditionally calls Maven versions plugin to set, update and commit the maven `versions:set`.
+
+:Required Parameters:
+
+    :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
+    :mvn-version: Version of Maven to execute Sonar with.
+    :mvn-pom: Location of pom.xml.
+    :maven-versions-plugin-set-version: Version number to upgrade to.
+    :mvn-settings: Maven settings.xml file containing credentials to use.
+
 lf-maven-stage
 ---------------
 
 Calls the maven stage script to push artifacts to a Nexus staging repository.
 
+:Required Parameters:
+
+    :mvn-global-settings: The name of the Maven global settings to use for
+        Maven configuration.
+    :mvn-settings: The name of settings file containing credentials for the project.
+
 lf-update-java-alternatives
 ---------------------------
 
@@ -323,11 +342,13 @@ directory is then used later to deploy to Nexus.
     :deploy-path:    The path in Nexus to deploy javadoc to. (default: $PROJECT/$STREAM)
     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
     :java-version: Version of Java to use for the build. (default: openjdk8)
+    :maven-versions-plugin: Whether to call Maven versions plugin or not. (default: false)
     :mvn-global-settings: The name of the Maven global settings to use for
         Maven configuration. (default: global-settings)
     :mvn-opts: Sets MAVEN_OPTS. (default: '')
     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
     :mvn-version: Version of maven to use. (default: mvn35)
+    :maven-versions-plugin-set-version: New version to use in Maven versions plugin. (default: '')
     :sign-artifacts: Sign artifacts with Sigul. (default: false)
     :stream: Keyword that can be used to represent a release code-name.
         Often the same as the branch. (default: master)
index 2d85978..286b620 100644 (file)
@@ -1,15 +1,33 @@
-The files in this directory are for initializing a Jenkins minion just before
-the cloud plugin hands the minion over to Jenkins.
+The files in this directory are for initializing a Jenkins minion just
+before the cloud plugin hands the minion over to Jenkins.
 
-init.sh is the entry point script which then calls all other scripts.
+The Jenkins 'init.sh' script will check for a project specific init
+script: '$ciman_root/jenkins-init-scripts/local-init.sh'.  If the file
+exits and is executable, it will be executed. Note the local init
+script will be executed before the 'jenkins' user has been created.
+You can also call a project specific script from the Jenkins Manged
+File after the call to 'init.sh'.
 
-init.sh also provides a local init script entry point by checking for the
-existance of the file CIMAN_ROOT/jenkins-init-scripts/local-init.sh. If this
-file exists it can be used to further customize the server node before handing
-it to Jenkins for job use.
-
-To use this create a managed file in Jenkins with the contents:
+To use this create a Jenkins Managed File with the contents:
 
     #!/bin/bash
-    git clone --recurse-submodules https://gerrit.example.org/r/ci-management.git /opt/ciman
-    /opt/ciman/jjb/global-jjb/jenkins-init-scripts/init.sh
+
+    gerrit_host=gerrit.example.org
+    ciman_root=/opt/ciman
+
+    until host $gerrit_host &>/dev/null ; do
+        echo "Waiting until $gerrit_host is resolvable..."
+        sleep 1
+    done
+
+    git clone --recurse-submodules https://$gerrit_host/r/ci-management $ciman_root
+
+    # Specify swapspace on the minion
+    # SWAP_SIZE specifies the size of swapspace in GB If set to '0' no
+    # swapspace will be allocated If unset, 1GB swapspace will be
+    # allocated
+    #export SWAP_SIZE=0
+
+    $ciman_root/global-jjb/jenkins-init-scripts/init.sh
+
+    rm -rf $ciman_root
index 0983129..e1e0b1e 100755 (executable)
 OS=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
 OS_RELEASE=$(facter lsbdistrelease | tr '[:upper:]' '[:lower:]')
 
-if [[ "$OS_RELEASE" == "18.04" ]] && [[ "$OS" == 'ubuntu' ]]
-then
-  echo 'PATH=$HOME/.local/bin:$PATH
-export PATH' >> /etc/profile
+if [[ "$OS_RELEASE" == "18.04" && "$OS" == 'ubuntu' ]]; then
+  echo 'export PATH=$HOME/.local/bin:$PATH' >> /etc/profile
 fi
 
 useradd -m -s /bin/bash jenkins
@@ -30,12 +28,13 @@ if grep -q mock /etc/group; then
 fi
 
 mkdir /home/jenkins/.ssh
-cp -r "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
+cp "/home/${OS}/.ssh/authorized_keys" /home/jenkins/.ssh/authorized_keys
+chmod 0600 /home/jenkins/.ssh/authorized_keys
 
 # Generate ssh key for use by Robot jobs
 echo -e 'y\n' | ssh-keygen -N "" -f /home/jenkins/.ssh/id_rsa -t rsa
 chown -R jenkins:jenkins /home/jenkins/.ssh
-chmod 700 /home/jenkins/.ssh
+chmod 0700 /home/jenkins/.ssh
 
 # The '/w' volume may already be part of image
 [[ ! -d '/w' ]] && mkdir /w
index 1bd2229..0ae7654 100755 (executable)
@@ -9,19 +9,20 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
-INIT_SCRIPTS_DIR="/opt/ciman/global-jjb/jenkins-init-scripts"
+ciman_init_scripts=$(readlink -f "$(dirname "$0")"/../../jenkins-init-scripts)
+jjb_init_scripts=$(readlink -f "$(dirname "$0")")
 
-"$INIT_SCRIPTS_DIR/package-listing.sh"
-"$INIT_SCRIPTS_DIR/basic-settings.sh"
-"$INIT_SCRIPTS_DIR/disable-firewall.sh"
-"$INIT_SCRIPTS_DIR/create-swap-file.sh"
+"$jjb_init_scripts/package-listing.sh"
+"$jjb_init_scripts/basic-settings.sh"
+"$jjb_init_scripts/disable-firewall.sh"
+"$jjb_init_scripts/create-swap-file.sh"
 
 # Entry point for additional local minion customization
-# Eg. OpenDaylight has additional bootstrap scripts depending on minion type.
-if [ -f "/opt/ciman/jenkins-init-scripts/local-init.sh" ]; then
-    /opt/ciman/jenkins-init-scripts/local-init.sh
+# Note this is called before the 'jenkins' account is created
+if [ -e "$ciman_init_scripts/local-init.sh" ]; then
+    "$ciman_init_scripts/local-init.sh"
 fi
 
 # Create the jenkins user last so that hopefully we DO NOT have to deal with
 # guard files
-"$INIT_SCRIPTS_DIR/create-jenkins-user.sh"
+"$jjb_init_scripts/create-jenkins-user.sh"
index 2598a22..93a2e74 100755 (executable)
@@ -9,9 +9,11 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
-# Share script with JJB jobs so we only have to maintain it in one place
-JJB_SHELL_DIR="$(dirname $0)/../shell"
+# The 'init' scripts are located in 'jenkins-init-scripts' directory.
+# The 'global-jjb' scripts are located in 'shell' directory.  The
+# 'package-listing' script is used by both, this is a simple wrapper
+# for 'shell/package-listing.sh'. Arguments would be quietly discarded.
 
-# Make sure the script is executable and then run it
-chmod +x "${JJB_SHELL_DIR}/package-listing.sh"
-"${JJB_SHELL_DIR}/package-listing.sh"
+jjb_init_scripts="$(dirname "$0")/../shell"
+
+"$jjb_init_scripts/package-listing.sh"
index bdcd65e..925ec4e 100644 (file)
     submodule-timeout: 10
     gerrit_jjb_deploy_job_triggers:
       - comment-added-contains-event:
-          comment-contains-value: 'jjb-deploy[:]* (?!\*+$).+$'
+          comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(jjb-deploy[:]* (?!\*+$).+$)'
 
     #####################
     # Job Configuration #
index 0c5abf6..eec378a 100644 (file)
           - ../shell/common-variables.sh
           - ../shell/maven-deploy.sh
 
+- builder:
+    name: lf-maven-versions-plugin
+    builders:
+      - conditional-step:
+          condition-kind: boolean-expression
+          condition-expression: '{maven-versions-plugin}'
+          steps:
+            - inject:
+                properties-file: version.properties
+            - maven-target:
+                maven-version: '{mvn-version}'
+                pom: '{mvn-pom}'
+                goals: 'versions:set versions:update-child-modules versions:commit -B'
+                properties:
+                  - 'newVersion=${{maven-versions-plugin-set-version}}'
+                settings: '{mvn-settings}'
+                settings-type: cfp
+                global-settings: 'global-settings'
+                global-settings-type: cfp
+
 - builder:
     name: lf-maven-stage
     builders:
     git-url: '$GIT_URL/$PROJECT'
     github-url: 'https://github.com'
     java-version: openjdk8
+    maven-versions-plugin: false
+    maven-versions-plugin-set-version: ''
     mvn-central: false
     mvn-global-settings: global-settings
     mvn-goals: clean deploy
     mvn-params: ''
     mvn-version: mvn35
     ossrh-profile-id: ''
+    mvn-pom: ''
     sign-artifacts: false
     sign-mode: serial
     stream: master
           global-settings-file: '{mvn-global-settings}'
           settings-file: '{mvn-settings}'
       - shell: !include-raw-escape: ../shell/maven-patch-release.sh
+      - lf-maven-versions-plugin:
+          maven-versions-plugin: '{maven-versions-plugin}'
+          mvn-version: '{mvn-version}'
+          mvn-pom: '{mvn-pom}'
+          maven-versions-plugin-set-version: '{maven-versions-plugin-set-version}'
+          mvn-settings: '{mvn-settings}'
       - lf-maven-build:
           mvn-goals: '{mvn-goals}'
       - lf-sigul-sign-dir:
diff --git a/releasenotes/notes/fix-lf-maven-central-macro-docs-ad43756dcd551c30.yaml b/releasenotes/notes/fix-lf-maven-central-macro-docs-ad43756dcd551c30.yaml
new file mode 100644 (file)
index 0000000..5d3794f
--- /dev/null
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Update the lf-maven-cental macro documentation and example templates with
+    the missing requireed params.
diff --git a/releasenotes/notes/optimize-jjb-deploy-regex-5ecc4287ecbc3317.yaml b/releasenotes/notes/optimize-jjb-deploy-regex-5ecc4287ecbc3317.yaml
new file mode 100644 (file)
index 0000000..8511d72
--- /dev/null
@@ -0,0 +1,18 @@
+---
+fixes:
+  - |
+    The JJB Deploy Job is configured to trigger only if the Gerrit comment
+    starts with the `jjb-deploy` keyword.
+
+    Without the regex being optimized the job triggers on any occurance
+    of the `jjb-deploy` keyword in a Gerrit comment, with is waste infra
+    resources.
+
+    Example of a valid command in Gerrit comment that triggers the job:
+
+    ``jjb-deploy builder-jjb-*``
+
+    Example of a invalid command in Gerrit comment that would _not_ trigger
+    the job:
+
+    ``Update the job. jjb-deploy builder-jjb-*``
diff --git a/releasenotes/notes/relocatable-init-scripts-3b1c5387fd723904.yaml b/releasenotes/notes/relocatable-init-scripts-3b1c5387fd723904.yaml
new file mode 100644 (file)
index 0000000..386197d
--- /dev/null
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    **jenkiins-init-scripts** The 'ciman' repo is not longer required to be
+    located in '/opt/ciman'.
diff --git a/releasenotes/notes/set-version-condition-dfdbd31461c99e5d.yaml b/releasenotes/notes/set-version-condition-dfdbd31461c99e5d.yaml
new file mode 100644 (file)
index 0000000..3c2bd4f
--- /dev/null
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    lf-maven-set-version conditional step for lf-maven-stage to allow
+    teams to run Maven versions plugin to update their artifact versions.
+    Step will run if maven-versions-plugin is set to true.