Merge "Document lf-infra-push-gerrit-patch macro in RTD"
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 8 Jun 2018 03:58:39 +0000 (03:58 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Fri, 8 Jun 2018 03:58:39 +0000 (03:58 +0000)
docs/configuration.rst
docs/jjb/lf-ci-jobs.rst
jjb/lf-macros.yaml
shell/create-netrc.sh
shell/jenkins-configure-clouds.sh
shell/jenkins-configure-global-vars.sh
shell/logs-clear-credentials.sh

index b15c19f..4c597cc 100644 (file)
@@ -65,7 +65,7 @@ Example Gerrit Infra:
        name: global
 
        # lf-infra defaults
-       jenkins-ssh-credential: opendaylight-jenkins-ssh
+       jenkins-ssh-credential: jenkins-ssh
        gerrit-server-name: OpenDaylight
        lftools-version: '<1.0.0'
        mvn-site-id: opendaylight-site
index de81269..e510d7c 100644 (file)
@@ -192,6 +192,8 @@ OpenStack Cloud plugin version supported:
 * 2.30
 * 2.31
 * 2.32
+* 2.33
+* 2.34
 
 Cloud configuration are managed via a directory structure in ci-management as
 follows:
index ef5cbd7..ba419c6 100644 (file)
           name: PROJECT
           default: '{project}'
           description: |
-              Parameter to identify a Gerrit project. This is typically the
-              project repo path as exists in Gerrit.
-              For example: ofextensions/circuitsw
+              Parameter to identify a SCM project to build. This is typically
+              the project repo path. For example: ofextensions/circuitsw
       - string:
           name: STREAM
           default: '{stream}'
           name: GERRIT_PROJECT
           default: '{project}'
           description: |
-              Parameter to identify Gerrit project. This is typically the
-              project repo path as exists in Gerrit.
-              For example: ofextensions/circuitsw
+              Gerrit Trigger provided parameter to identify Gerrit project that
+              triggered the build. This is typically the project repo path as
+              exists in Gerrit. For example: ofextensions/circuitsw
 
-              Note that Gerrit will override this parameter automatically if a
-              job is triggered by Gerrit.
+              If using Gerrit, in a manual build this should match the PROJECT
+              parameter above.
       - string:
           name: GERRIT_BRANCH
           default: '{branch}'
           description: |
-              Parameter to identify a Gerrit branch.
+              Gerrit Trigger provided parameter to identify a Gerrit branch.
 
-              Note that Gerrit will override this parameter automatically if a
-              job is triggered by Gerrit.
+              If using Gerrit, in a manual build override with the branch to
+              build against.
       - string:
           name: GERRIT_REFSPEC
           default: 'refs/heads/{branch}'
           description: |
-              Parameter to identify a refspec when pulling from Gerrit.
+              Gerrit Trigger provided parameter to identify a refspec to fetch
+              from Gerrit.
 
-              Note that Gerrit will override this parameter automatically if a
-              job is triggered by Gerrit.
+              If using Gerrit, in a manual build override with a refspec.
+              https://git-scm.com/book/en/v2/Git-Internals-The-Refspec
+              For example: 'refs/heads/master'
+      - string:
+          name: sha1
+          default: 'origin/{branch}'
+          description: |
+              GitHub PR Trigger provided parameter for specifying the commit
+              to checkout.
+
+              If using GitHub, in a manual build override with a branch path or
+              sha1 hash to a specific commit. For example: 'origin/master'
+      # Tools
       - string:
           name: LFTOOLS_VERSION
           default: '{lftools-version}'
index 52f239d..a123be8 100644 (file)
 ##############################################################################
 echo "---> create-netrc.sh"
 
-# Ensure we fail the job if any steps fail.
-set -eu -o pipefail
-
-ALT_NEXUS_URL="${ALT_NEXUS_URL:-}"
-
-if [ -z "$ALT_NEXUS_URL" ]
-then
+if [ -z "$ALT_NEXUS_URL" ]; then
     NEXUS_URL="${NEXUSPROXY:-$NEXUS_URL}"
 else
     NEXUS_URL="${ALT_NEXUS_URL}"
 fi
-
 CREDENTIAL=$(xmlstarlet sel -N "x=http://maven.apache.org/SETTINGS/1.0.0" \
     -t -m "/x:settings/x:servers/x:server[x:id='${SERVER_ID}']" \
     -v x:username -o ":" -v x:password \
     "$SETTINGS_FILE")
 
+# Ensure we fail the job if any steps fail.
+set -eu -o pipefail
+
+# Handle when a project chooses to not archive logs to a log server
+# in other cases if CREDENTIAL is not found then fail the build.
+if [ -z "$CREDENTIAL" ] && [ "$SERVER_ID" == "logs" ]; then
+    echo "WARN: Log server credential not found."
+    exit 0
+elif [ -z "$CREDENTIAL" ]; then
+    echo "ERROR: Credential not found."
+    exit 1
+fi
+
 machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
 user=$(echo "$CREDENTIAL" | cut -f1 -d:)
 pass=$(echo "$CREDENTIAL" | cut -f2 -d:)
 
+set +x  # Disable `set -x` to prevent printing passwords
 echo "machine ${machine%:*} login $user password $pass" > ~/.netrc
index cd50da0..3f7dd6a 100644 (file)
@@ -158,7 +158,7 @@ get_minion_options() {
     security_groups=$(get_cfg "$cfg_file" SECURITY_GROUPS "default")
     availability_zone=$(get_cfg "$cfg_file" AVAILABILITY_ZONE "")
     start_timeout=$(get_cfg "$cfg_file" START_TIMEOUT "600000")
-    key_pair_name=$(get_cfg "$cfg_file" KEY_PAIR_NAME "jenkins")
+    key_pair_name=$(get_cfg "$cfg_file" KEY_PAIR_NAME "jenkins-ssh")
     num_executors=$(get_cfg "$cfg_file" NUM_EXECUTORS "1")
     jvm_options=$(get_cfg "$cfg_file" JVM_OPTIONS "")
     fs_root=$(get_cfg "$cfg_file" FS_ROOT "/w")
@@ -181,7 +181,7 @@ get_minion_options() {
     echo "    $num_executors,"
     echo "    \"$jvm_options\","
     echo "    \"$fs_root\","
-    echo "    new LauncherFactory.SSH(\"jenkins\", \"\"),"
+    echo "    new LauncherFactory.SSH(\"$key_pair_name\", \"\"),"
     echo "    $retention_time"
 }
 
index 6e64023..af36d10 100644 (file)
@@ -27,6 +27,13 @@ silos="${jenkins_silos:-jenkins}"
 set -eu -o pipefail
 
 for silo in $silos; do
+    if [ ! -f "$WORKSPACE/jenkins-config/global-vars-$silo.sh" ]; then
+        echo "WARN: jenkins-config/global-vars-$silo.sh does not exist. Skipping cloud management..."
+        echo "We highly recommend setting up global-vars-$silo.sh to manage the Jenkins global variables."
+        echo "Refer to https://docs.releng.linuxfoundation.org/projects/global-jjb/en/latest/jjb/lf-ci-jobs.html#global-environment-variables for details."
+        continue
+    fi
+
     set +x  # Ensure that no other scripts add `set -x` and print passwords
     echo "Configuring $silo"
 
index 74dbae3..a4a8cdd 100644 (file)
@@ -10,5 +10,5 @@
 ##############################################################################
 
 # Clear log credential files
-rm "$SETTINGS_FILE"
-rm ~/.netrc
+rm -f "$SETTINGS_FILE"
+rm -f ~/.netrc