Merge "Install git-review outside of loop"
authorJamo Luhrsen <jluhrsen@redhat.com>
Fri, 12 Jan 2018 06:08:46 +0000 (06:08 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Fri, 12 Jan 2018 06:08:46 +0000 (06:08 +0000)
.jjb-test/expected-xml/gerrit-maven-maven-clm-master
.jjb-test/expected-xml/gerrit-python-tox-verify-master
.jjb-test/expected-xml/gerrit-rtd-rtd-verify-master
.jjb-test/expected-xml/github-maven-maven-clm-master
.jjb-test/expected-xml/github-python-tox-verify-master
.jjb-test/expected-xml/github-rtd-rtd-verify-master
docs/jjb/lf-python-jobs.rst
jjb/lf-maven-jobs.yaml
jjb/lf-python-jobs.yaml
shell/tox-install.sh
shell/tox-run.sh

index e028a8a..e029666 100644 (file)
@@ -157,6 +157,51 @@ For example '&lt;1.0.0' or '&gt;=1.0.0,&lt;2.0.0'.
     <hudson.triggers.TimerTrigger>
       <spec>H H * * 6</spec>
     </hudson.triggers.TimerTrigger>
+    <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
+      <spec/>
+      <gerritProjects>
+        <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
+          <compareType>ANT</compareType>
+          <pattern>releng/ciman</pattern>
+          <branches>
+            <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
+              <compareType>ANT</compareType>
+              <pattern>**/master</pattern>
+            </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
+          </branches>
+          <disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
+        </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
+      </gerritProjects>
+      <skipVote>
+        <onSuccessful>true</onSuccessful>
+        <onFailed>true</onFailed>
+        <onUnstable>true</onUnstable>
+        <onNotBuilt>true</onNotBuilt>
+      </skipVote>
+      <silentMode>false</silentMode>
+      <silentStartMode>false</silentStartMode>
+      <escapeQuotes>true</escapeQuotes>
+      <noNameAndEmailParameters>false</noNameAndEmailParameters>
+      <readableMessage>false</readableMessage>
+      <dependencyJobsNames/>
+      <notificationLevel/>
+      <dynamicTriggerConfiguration>False</dynamicTriggerConfiguration>
+      <triggerConfigURL/>
+      <allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
+      <triggerOnEvents>
+        <com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
+          <commentAddedCommentContains>run-clm$</commentAddedCommentContains>
+        </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
+      </triggerOnEvents>
+      <buildStartMessage/>
+      <buildFailureMessage/>
+      <buildSuccessfulMessage/>
+      <buildUnstableMessage/>
+      <buildNotBuiltMessage/>
+      <buildUnsuccessfulFilepath/>
+      <customUrl/>
+      <serverName>test-server</serverName>
+    </com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
   </triggers>
   <builders>
     <hudson.tasks.Shell>
index 497228e..18976d1 100644 (file)
@@ -274,6 +274,11 @@ lftools --version
 # pipdeptree
 </command>
     </hudson.tasks.Shell>
+    <EnvInjectBuilder>
+      <info>
+        <propertiesContent>PYTHON_VERSION=python3</propertiesContent>
+      </info>
+    </EnvInjectBuilder>
     <hudson.tasks.Shell>
       <command>#!/bin/bash
 # SPDX-License-Identifier: EPL-1.0
@@ -291,17 +296,19 @@ echo &quot;---&gt; tox-install.sh&quot;
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
-virtualenv --quiet &quot;/tmp/v/tox&quot;
+virtualenv --quiet -p &quot;$PYTHON_VERSION&quot; &quot;/tmp/v/tox&quot;
 # shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
 source &quot;/tmp/v/tox/bin/activate&quot;
 pip install --quiet --upgrade pip
 pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade detox tox argparse
+pip install --quiet --upgrade argparse detox tox tox-pyenv
 
 echo &quot;----&gt; Pip Dependency Tree&quot;
 pipdeptree
-
-#!/bin/bash
+</command>
+    </hudson.tasks.Shell>
+    <hudson.tasks.Shell>
+      <command>#!/bin/bash
 # SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2017 The Linux Foundation and others.
@@ -313,28 +320,43 @@ pipdeptree
 ##############################################################################
 echo &quot;---&gt; tox-run.sh&quot;
 
+# shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
+source &quot;/tmp/v/tox/bin/activate&quot;
+
 # Ensure we fail the job if any steps fail.
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
 ARCHIVE_TOX_DIR=&quot;$WORKSPACE/archives/tox&quot;
 mkdir -p &quot;$ARCHIVE_TOX_DIR&quot;
-
 cd &quot;$WORKSPACE/$TOX_DIR&quot;
 
+if [ -d &quot;/opt/pyenv&quot; ]; then
+    echo &quot;---&gt; Setting up pyenv&quot;
+    export PYENV_ROOT=&quot;/opt/pyenv&quot;
+    export PATH=&quot;$PYENV_ROOT/bin:$PATH&quot;
+fi
+
+set +e  # Allow detox to fail so that we can collect the logs in the next step
 if [ ! -z &quot;$TOX_ENVS&quot; ]; then
     detox -e &quot;$TOX_ENVS&quot;  | tee -a &quot;$ARCHIVE_TOX_DIR/detox.log&quot;
+    detox_status=&quot;${PIPESTATUS[0]}&quot;
 else
     detox | tee -a &quot;$ARCHIVE_TOX_DIR/detox.log&quot;
+    detox_status=&quot;${PIPESTATUS[0]}&quot;
 fi
 
 # Disable SC2116 as we want to echo a space separated list of TOX_ENVS
 # shellcheck disable=SC2116
-for i in $(echo &quot;${TOX_ENVS//,/ }&quot;); do
-    cp -r &quot;.tox/$i/log&quot; &quot;$ARCHIVE_TOX_DIR/$i&quot;
+for i in .tox/*/log; do
+    tox_env=$(echo $i | awk -F'/' '{print $2}')
+    cp -r &quot;$i&quot; &quot;$ARCHIVE_TOX_DIR/$tox_env&quot;
 done
+set -e  # Logs collected so re-enable
 
 echo &quot;Completed tox runs.&quot;
+
+test &quot;$detox_status&quot; -eq 0 || exit &quot;$detox_status&quot;
 </command>
     </hudson.tasks.Shell>
   </builders>
index 5bc67ea..b47f5e3 100644 (file)
@@ -205,12 +205,12 @@ echo &quot;---&gt; tox-install.sh&quot;
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
-virtualenv --quiet &quot;/tmp/v/tox&quot;
+virtualenv --quiet -p &quot;$PYTHON_VERSION&quot; &quot;/tmp/v/tox&quot;
 # shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
 source &quot;/tmp/v/tox/bin/activate&quot;
 pip install --quiet --upgrade pip
 pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade detox tox argparse
+pip install --quiet --upgrade argparse detox tox tox-pyenv
 
 echo &quot;----&gt; Pip Dependency Tree&quot;
 pipdeptree
index ddd663c..ca73ec3 100644 (file)
@@ -149,9 +149,24 @@ For example '&lt;1.0.0' or '&gt;=1.0.0,&lt;2.0.0'.
     </extensions>
   </scm>
   <triggers class="vector">
-    <hudson.triggers.TimerTrigger>
-      <spec>H H * * 6</spec>
-    </hudson.triggers.TimerTrigger>
+    <org.jenkinsci.plugins.ghprb.GhprbTrigger>
+      <spec/>
+      <adminlist/>
+      <allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
+      <whitelist/>
+      <orgslist/>
+      <cron/>
+      <triggerPhrase>^run-clm$</triggerPhrase>
+      <onlyTriggerPhrase>false</onlyTriggerPhrase>
+      <useGitHubHooks>true</useGitHubHooks>
+      <permitAll>true</permitAll>
+      <autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
+      <extensions>
+        <org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
+          <commitStatusContext>CLM</commitStatusContext>
+        </org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus>
+      </extensions>
+    </org.jenkinsci.plugins.ghprb.GhprbTrigger>
   </triggers>
   <builders>
     <hudson.tasks.Shell>
index 9cd8ea3..d499bbd 100644 (file)
@@ -236,6 +236,11 @@ lftools --version
 # pipdeptree
 </command>
     </hudson.tasks.Shell>
+    <EnvInjectBuilder>
+      <info>
+        <propertiesContent>PYTHON_VERSION=python3</propertiesContent>
+      </info>
+    </EnvInjectBuilder>
     <hudson.tasks.Shell>
       <command>#!/bin/bash
 # SPDX-License-Identifier: EPL-1.0
@@ -253,17 +258,19 @@ echo &quot;---&gt; tox-install.sh&quot;
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
-virtualenv --quiet &quot;/tmp/v/tox&quot;
+virtualenv --quiet -p &quot;$PYTHON_VERSION&quot; &quot;/tmp/v/tox&quot;
 # shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
 source &quot;/tmp/v/tox/bin/activate&quot;
 pip install --quiet --upgrade pip
 pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade detox tox argparse
+pip install --quiet --upgrade argparse detox tox tox-pyenv
 
 echo &quot;----&gt; Pip Dependency Tree&quot;
 pipdeptree
-
-#!/bin/bash
+</command>
+    </hudson.tasks.Shell>
+    <hudson.tasks.Shell>
+      <command>#!/bin/bash
 # SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2017 The Linux Foundation and others.
@@ -275,28 +282,43 @@ pipdeptree
 ##############################################################################
 echo &quot;---&gt; tox-run.sh&quot;
 
+# shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
+source &quot;/tmp/v/tox/bin/activate&quot;
+
 # Ensure we fail the job if any steps fail.
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
 ARCHIVE_TOX_DIR=&quot;$WORKSPACE/archives/tox&quot;
 mkdir -p &quot;$ARCHIVE_TOX_DIR&quot;
-
 cd &quot;$WORKSPACE/$TOX_DIR&quot;
 
+if [ -d &quot;/opt/pyenv&quot; ]; then
+    echo &quot;---&gt; Setting up pyenv&quot;
+    export PYENV_ROOT=&quot;/opt/pyenv&quot;
+    export PATH=&quot;$PYENV_ROOT/bin:$PATH&quot;
+fi
+
+set +e  # Allow detox to fail so that we can collect the logs in the next step
 if [ ! -z &quot;$TOX_ENVS&quot; ]; then
     detox -e &quot;$TOX_ENVS&quot;  | tee -a &quot;$ARCHIVE_TOX_DIR/detox.log&quot;
+    detox_status=&quot;${PIPESTATUS[0]}&quot;
 else
     detox | tee -a &quot;$ARCHIVE_TOX_DIR/detox.log&quot;
+    detox_status=&quot;${PIPESTATUS[0]}&quot;
 fi
 
 # Disable SC2116 as we want to echo a space separated list of TOX_ENVS
 # shellcheck disable=SC2116
-for i in $(echo &quot;${TOX_ENVS//,/ }&quot;); do
-    cp -r &quot;.tox/$i/log&quot; &quot;$ARCHIVE_TOX_DIR/$i&quot;
+for i in .tox/*/log; do
+    tox_env=$(echo $i | awk -F'/' '{print $2}')
+    cp -r &quot;$i&quot; &quot;$ARCHIVE_TOX_DIR/$tox_env&quot;
 done
+set -e  # Logs collected so re-enable
 
 echo &quot;Completed tox runs.&quot;
+
+test &quot;$detox_status&quot; -eq 0 || exit &quot;$detox_status&quot;
 </command>
     </hudson.tasks.Shell>
   </builders>
index 3bf0043..cf393fb 100644 (file)
@@ -157,12 +157,12 @@ echo &quot;---&gt; tox-install.sh&quot;
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
-virtualenv --quiet &quot;/tmp/v/tox&quot;
+virtualenv --quiet -p &quot;$PYTHON_VERSION&quot; &quot;/tmp/v/tox&quot;
 # shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
 source &quot;/tmp/v/tox/bin/activate&quot;
 pip install --quiet --upgrade pip
 pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade detox tox argparse
+pip install --quiet --upgrade argparse detox tox tox-pyenv
 
 echo &quot;----&gt; Pip Dependency Tree&quot;
 pipdeptree
index 624026d..a047724 100644 (file)
@@ -23,6 +23,21 @@ Jobs for Python projects using GitHub.
 
     - github-tox-verify
 
+
+Macros
+======
+
+lf-tox-install
+--------------
+
+Runs a shell script that installs tox in a Python virtualenv.
+
+:Required Parameters:
+
+    :python-version: Base Python version to use in the virtualenv. For example
+        python2 or python3.
+
+
 Job Templates
 =============
 
@@ -49,6 +64,8 @@ Tox runner to verify a project
     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
     :build-timeout: Timeout in seconds before aborting build. (default: 10)
     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
+    :python-version: Version of Python to configure as a base in virtualenv.
+        (default: python3)
     :stream: Keyword representing a release code-name.
         Often the same as the branch. (default: master)
     :submodule-recursive: Whether to checkout submodules recursively.
index 8d4d837..47c2555 100644 (file)
     stream: master
     submodule-recursive: true
 
+    gerrit_clm_triggers:
+      - comment-added-contains-event:
+          comment-contains-value: run-clm$
+
     #####################
     # Job Configuration #
     #####################
     triggers:
       # Build weekly on Saturdays
       - timed: 'H H * * 6'
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on: '{obj:gerrit_clm_triggers}'
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: '**/{branch}'
+          skip-vote:
+            successful: true
+            failed: true
+            unstable: true
+            notbuilt: true
 
     builders:
       - lf-maven-install:
           choosing-strategy: default
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
 
+    triggers:
+      - lf-infra-github-pr-trigger:
+          trigger-phrase: '^run-clm$'
+          only-trigger-phrase: false
+          status-context: 'CLM'
+          permit-all: true
+          github-hooks: true
+          github-org: ''
+          github_pr_whitelist:
+            - ''
+          github_pr_admin_list:
+            - ''
+
 #########################
 # Maven Javadoc Publish #
 #########################
index 4011822..81f681b 100644 (file)
     jobs:
       - github-tox-verify
 
+##########
+# Macros #
+##########
+
+- builder:
+    name: lf-infra-tox-install
+    builders:
+      - inject:
+          properties-content: 'PYTHON_VERSION={python-version}'
+      - shell: !include-raw-escape: ../shell/tox-install.sh
+
 ##############
 # Tox Verify #
 ##############
@@ -32,6 +43,7 @@
     build-days-to-keep: 7
     build-timeout: 10
     git-url: '$GIT_URL/$GERRIT_PROJECT'
+    python-version: python3
     stream: master
     submodule-recursive: true
     tox-dir: ''
@@ -70,9 +82,9 @@
           # Without running the install first the run in the publisher will fail
           # due to missing lftools because it gets installed into a tox venv.
           - ../shell/lftools-install.sh
-      - shell: !include-raw-escape:
-          - ../shell/tox-install.sh
-          - ../shell/tox-run.sh
+      - lf-infra-tox-install:
+          python-version: '{python-version}'
+      - shell: !include-raw-escape: ../shell/tox-run.sh
 
     publishers:
       - lf-infra-publish
index e6f2614..652043b 100644 (file)
@@ -14,12 +14,12 @@ echo "---> tox-install.sh"
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
-virtualenv --quiet "/tmp/v/tox"
+virtualenv --quiet -p "$PYTHON_VERSION" "/tmp/v/tox"
 # shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
 source "/tmp/v/tox/bin/activate"
 pip install --quiet --upgrade pip
 pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade detox tox argparse
+pip install --quiet --upgrade argparse detox tox tox-pyenv
 
 echo "----> Pip Dependency Tree"
 pipdeptree
index 97f8855..7abdeea 100644 (file)
 ##############################################################################
 echo "---> tox-run.sh"
 
+# shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
+source "/tmp/v/tox/bin/activate"
+
 # Ensure we fail the job if any steps fail.
 # DO NOT set -u as virtualenv's activate script has unbound variables
 set -e -o pipefail
 
 ARCHIVE_TOX_DIR="$WORKSPACE/archives/tox"
 mkdir -p "$ARCHIVE_TOX_DIR"
-
 cd "$WORKSPACE/$TOX_DIR"
 
+if [ -d "/opt/pyenv" ]; then
+    echo "---> Setting up pyenv"
+    export PYENV_ROOT="/opt/pyenv"
+    export PATH="$PYENV_ROOT/bin:$PATH"
+fi
+
+set +e  # Allow detox to fail so that we can collect the logs in the next step
 if [ ! -z "$TOX_ENVS" ]; then
     detox -e "$TOX_ENVS"  | tee -a "$ARCHIVE_TOX_DIR/detox.log"
+    detox_status="${PIPESTATUS[0]}"
 else
     detox | tee -a "$ARCHIVE_TOX_DIR/detox.log"
+    detox_status="${PIPESTATUS[0]}"
 fi
 
 # Disable SC2116 as we want to echo a space separated list of TOX_ENVS
 # shellcheck disable=SC2116
-for i in $(echo "${TOX_ENVS//,/ }"); do
-    cp -r ".tox/$i/log" "$ARCHIVE_TOX_DIR/$i"
+for i in .tox/*/log; do
+    tox_env=$(echo $i | awk -F'/' '{print $2}')
+    cp -r "$i" "$ARCHIVE_TOX_DIR/$tox_env"
 done
+set -e  # Logs collected so re-enable
 
 echo "Completed tox runs."
+
+test "$detox_status" -eq 0 || exit "$detox_status"