Merge "Add WhiteSource Scan jobs"
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 4 Apr 2019 19:59:03 +0000 (19:59 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Thu, 4 Apr 2019 19:59:03 +0000 (19:59 +0000)
18 files changed:
.jjb-test/lf-ci-jobs.yaml
docs/jjb/lf-ci-jobs.rst
docs/jjb/lf-info-vote.rst [new file with mode: 0644]
docs/jjb/lf-macros.rst
jjb/lf-ci-jobs.yaml
jjb/lf-info-vote.yaml [new file with mode: 0644]
jjb/lf-macros.yaml
jjb/lf-maven-jobs.yaml
releasenotes/notes/fix_openjdk-11_centos7.yaml [new file with mode: 0644]
releasenotes/notes/jjb-workers-9459a54a5ecb91e8.yaml [new file with mode: 0644]
releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml [new file with mode: 0644]
releasenotes/notes/mvn-verify-skip-source-39f1e748f5505d4c.yaml [new file with mode: 0644]
releasenotes/notes/throttle-jjb-f9589760648e067d.yaml [new file with mode: 0644]
shell/check-info-votes.sh [new file with mode: 0644]
shell/comment-to-gerrit.sh [new file with mode: 0644]
shell/jjb-merge-job.sh
shell/python-tools-install.sh
shell/update-java-alternatives.sh

index 5e716d9..c88fa92 100644 (file)
       - java-builder
       - mininet
 
+- project:
+    name: throttle-ci-jobs
+    jobs:
+      - "{project-name}-ci-jobs"
+
+    throttle-enabled: true
+    throttle_categories:
+      - 'cat1'
+      - 'cat2'
+    throttle-max-per-node: 3
+    throttle-max-total: 2
+    throttle-option: 'category'
+
+    project-name: throttle-ciman
+
 - project:
     name: ci-jobs-view
     views:
index 79c0929..5ad9b6a 100644 (file)
@@ -424,6 +424,8 @@ Runs `jenkins-jobs update` to update production job configuration
     :build-timeout: Timeout in minutes before aborting build. (default: 10)
     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
     :jjb-cache: JJB cache location. (default: $HOME/.cache/jenkins_jobs)
+    :jjb-workers: Number of threads to run **update** with. Set to 0 by default
+        which is equivalent to the number of available CPU cores. (default: 0)
     :jjb-version: JJB version to install. (default: see job-template)
     :stream: Keyword that can be used to represent a release code-name.
         Often the same as the branch. (default: master)
@@ -474,6 +476,15 @@ Runs `jenkins-jobs test` to validate JJB syntax
         (default: true)
     :submodule-timeout: Timeout (in minutes) for checkout operation.
         (default: 10)
+    :throttle_categories: List of categories to throttle by.
+    :throttle-enabled: Whether or not to enable throttling on the job.
+        (default: true)
+    :throttle-max-per-node: Max jobs to run on the same node. (default: 1)
+    :throttle-max-total: Max jobs to run across the entire project. - 0
+        means 'unlimited' (default: 0)
+    :throttle-option: Throttle by the project or by list of categories
+        defined in the throttle plugin configuration. (options: 'project',
+        'category'; default: project)
 
     :gerrit_verify_triggers: Override Gerrit Triggers.
     :gerrit_trigger_file_paths: Override file paths which can be used to
diff --git a/docs/jjb/lf-info-vote.rst b/docs/jjb/lf-info-vote.rst
new file mode 100644 (file)
index 0000000..76c6d3d
--- /dev/null
@@ -0,0 +1,25 @@
+.. _lf-global-jjb-info-vote:
+
+#############
+INFO VOTE JOB
+#############
+
+Job counts the votes from the committers against a change
+to the INFO.yaml file
+
+If needed, will also check for a majority of tsc voters
+(not yet implemented)
+
+Auto-merges the change on a majority vote.
+
+
+info-vote
+---------
+
+:Comment Trigger: recheck|reverify|Vote
+
+:Required parameters:
+
+    :build-node: The node to run build on.
+    :jenkins-ssh-credential: Credential to use for SSH. (Generally set
+        in defaults.yaml)
index 94fcb1c..133795e 100644 (file)
@@ -5,6 +5,14 @@ Global Macros
 Builders
 ========
 
+comment-to-gerrit
+-----------------
+
+This macro will post a comment to the gerrit patchset if the build
+creates a file named gerrit_comment.txt
+To use this macro add it to the list of builders.
+
+
 lf-fetch-dependent-patches
 --------------------------
 
@@ -234,6 +242,11 @@ lf-rtd-verify
 
 ReadTheDocs verify script.
 
+check-info-votes
+----------------
+
+Calls shell script to validate votes on a change to an INFO.yaml
+
 lf-sigul-sign-dir
 -----------------
 
index 925ec4e..ebf637f 100644 (file)
     stream: master
     submodule-recursive: true
     submodule-timeout: 10
+    throttle_categories: []
+    throttle-enabled: false
+    throttle-max-per-node: 1
+    throttle-max-total: 0
+    throttle-option: 'project'
 
     gerrit_trigger_file_paths:
       - compare-type: REG_EXP
       - lf-infra-properties:
           project: '{project}'
           build-days-to-keep: 7
+      - throttle:
+          categories: '{obj:throttle_categories}'
+          enabled: '{throttle-enabled}'
+          max-per-node: '{throttle-max-per-node}'
+          max-total: '{throttle-max-total}'
+          option: '{throttle-option}'
 
     parameters:
       - lf-infra-parameters:
     # Default parameters #
     ######################
 
+    jjb-workers: 0
+
     gerrit_merge_triggers:
       - change-merged-event
       - comment-added-contains-event:
     builders:
       - lf-infra-pre-build
       - lf-infra-jjbini
+      - inject:
+          properties-content: JJB_WORKERS={jjb-workers}
       - shell: !include-raw-escape:
           - ../shell/jjb-install.sh
           - ../shell/jjb-merge-job.sh
diff --git a/jjb/lf-info-vote.yaml b/jjb/lf-info-vote.yaml
new file mode 100644 (file)
index 0000000..012400f
--- /dev/null
@@ -0,0 +1,105 @@
+---
+####################
+# COMMON FUNCTIONS #
+####################
+
+- lf_info_vote_common: &lf_info_vote_common
+    name: lf-info-vote-common
+
+    gerrit_trigger_file_paths:
+      - compare-type: REG_EXP
+        pattern: 'INFO.yaml'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    project-type: freestyle
+    node: '{build-node}'
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: 7
+
+    parameters:
+      - lf-infra-parameters:
+          project: $GERRIT_PROJECT
+          branch: 'master'
+          refspec: 'refs/heads/{branch}'
+          stream: 'master'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    publishers:
+      - lf-infra-publish
+
+
+- lf_info_vote_verify: &lf_info_vote_verify
+    name: lf-info-vote-verify
+
+    branch: master
+    stream: master
+    build-days-to-keep: 7
+    build-timeout: 15
+    disable-job: false
+    git-url: '$GIT_URL/$PROJECT'
+    submodule-timeout: 10
+    submodule-recursive: true
+    gerrit-skip-vote: false
+
+    gerrit_verify_triggers:
+      - comment-added-contains-event:
+          comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(vote)$'
+      - comment-added:
+          approval-category: 'CRVW'
+          approval-value: '+2'
+      - comment-added:
+          approval-category: 'Code-Review'
+          approval-value: '+2'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    disabled: '{disable-job}'
+
+    builders:
+      - check-info-votes:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+- job-template:
+    name: 'info-vote'
+    id: info-vote-verify
+    <<: *lf_info_vote_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_info_vote_verify
+
+    scm:
+      - lf-infra-gerrit-scm:
+          branch: '$GERRIT_BRANCH'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          choosing-strategy: gerrit
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on: '{obj:gerrit_verify_triggers}'
+          projects:
+            - project-compare-type: 'REG_EXP'
+              project-pattern: '**'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**/master'
+              file-paths: '{obj:gerrit_trigger_file_paths}'
+          skip-vote:
+            successful: '{gerrit-skip-vote}'
+            failed: '{gerrit-skip-vote}'
+            unstable: '{gerrit-skip-vote}'
+            notbuilt: '{gerrit-skip-vote}'
index 6b3faa8..134ef13 100644 (file)
@@ -3,6 +3,14 @@
 # BUILDERS #
 ############
 
+# To take advantage of this macro, have your build write
+# out the file 'gerrit_comment.txt' with information to post
+# back to gerrit and include this macro in the list of builders.
+- builder:
+    name: comment-to-gerrit
+    builders:
+      - shell: !include-raw ../shell/comment-to-gerrit.sh
+
 - builder:
     name: lf-fetch-dependent-patches
     builders:
       - shell: !include-raw-escape: ../shell/tox-install.sh
       - shell: !include-raw-escape: ../shell/rtd-verify.sh
 
+- builder:
+    name: check-info-votes
+    builders:
+      - inject:
+          properties-content: JENKINS_SSH_CREDENTIAL={jenkins-ssh-credential}
+      - shell: !include-raw-escape: ../shell/check-info-votes.sh
+
 - builder:
     name: lf-sigul-sign-dir
     # Requires that Jenkins be configured with SIGUL_BRIDGE_IP as a global
index eec378a..dea836b 100644 (file)
     mvn-global-settings: global-settings
     mvn-goals: clean deploy
     mvn-opts: ''
-    mvn-params: '-Dstream=$STREAM'
+    mvn-params: '-Dstream=$STREAM -Dmaven.source.skip=true'
     mvn-version: mvn35
     stream: master
     submodule-recursive: true
diff --git a/releasenotes/notes/fix_openjdk-11_centos7.yaml b/releasenotes/notes/fix_openjdk-11_centos7.yaml
new file mode 100644 (file)
index 0000000..8e05014
--- /dev/null
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fix JAVA_HOME for openjdk11 on CentOS 7 to use the OpenJDK version installed
+    in /usr/lib/jvm/java-11-openjdk.
diff --git a/releasenotes/notes/jjb-workers-9459a54a5ecb91e8.yaml b/releasenotes/notes/jjb-workers-9459a54a5ecb91e8.yaml
new file mode 100644 (file)
index 0000000..fc11d25
--- /dev/null
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    The **jjb-merge** job now has a new parameter ``jjb-workers`` to allow
+    configuration of the number of threads to run update with. Default is *0*
+    which is equivalent to the number of CPU cores available on the system.
diff --git a/releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml b/releasenotes/notes/lf-info-vote-74329a41dfea62be.yaml
new file mode 100644 (file)
index 0000000..e94e31d
--- /dev/null
@@ -0,0 +1,7 @@
+---
+features:
+  - |
+    New ``info-vote-verify`` macro
+    Will count votes against an INFO.yaml change and sumbit
+    automatically if a majority of committers and tsc mebers
+    vote +1 or +2 on the change.
diff --git a/releasenotes/notes/mvn-verify-skip-source-39f1e748f5505d4c.yaml b/releasenotes/notes/mvn-verify-skip-source-39f1e748f5505d4c.yaml
new file mode 100644 (file)
index 0000000..36470ae
--- /dev/null
@@ -0,0 +1,6 @@
+---
+other:
+  - |
+    The Maven Verify job will now call ``-Dmaven.source.skip`` to skip source
+    jar generation in the verify job. This saves us some time in the verify
+    build as the source artifacts are not useful in a verify job.
diff --git a/releasenotes/notes/throttle-jjb-f9589760648e067d.yaml b/releasenotes/notes/throttle-jjb-f9589760648e067d.yaml
new file mode 100644 (file)
index 0000000..ee2da33
--- /dev/null
@@ -0,0 +1,11 @@
+---
+features:
+  - |
+    Support for the `Throttle Plugin`_ is added to JJB jobs so static
+    build servers can restrict the number of concurrent JJB jobs ran at
+    the same time.
+
+    This must be explicitly enabled by setting `throttle-enabled` on the
+    jobs.
+
+    .. _Throttle Plugin: https://plugins.jenkins.io/throttle-concurrents
diff --git a/shell/check-info-votes.sh b/shell/check-info-votes.sh
new file mode 100644 (file)
index 0000000..892dd89
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+echo "---> check-info-votes.sh"
+set -xe -o pipefail
+
+ref=$(echo "$GERRIT_REFSPEC" | awk -F"/" '{ print $4 }')
+pip="pip3"
+
+# For OPNFV
+if [[ $NODE_NAME =~ "lf-build" ]]; then
+  pip=pip
+fi
+
+if [ -d "/opt/pyenv" ]; then
+  echo "---> Setting up pyenv"
+  export PYENV_ROOT="/opt/pyenv"
+  export PATH="$PYENV_ROOT/bin:$PATH"
+  PYTHONPATH=$(pwd)
+  export PYTHONPATH
+  pyenv local 3.6.4
+  export PYENV_VERSION="3.6.4"
+fi
+
+$pip install --user niet
+$pip install --user lftools
+$pip install --user lftools[nexus]
+$pip install --user jsonschema
+
+change="$(echo "$GERRIT_CHANGE_URL" | awk -F"/" '{print $NF}')"
+echo "Checking votes:"
+lftools infofile check-votes INFO.yaml "$GERRIT_URL" "$ref" > gerrit_comment.txt
+exit_status="$?"
+
+if [[ "$exit_status" -ne 0 ]]; then
+  echo "Vote not yet complete"
+  cat gerrit_comment.txt
+  exit "$exit_status"
+else
+  echo "Vote completed submitting review"
+  ssh -p "$GERRIT_PORT" "$JENKINS_SSH_CREDENTIAL"@"$GERRIT_HOST" gerrit review "$change" --submit
+fi
diff --git a/shell/comment-to-gerrit.sh b/shell/comment-to-gerrit.sh
new file mode 100644 (file)
index 0000000..b4d3d66
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2019 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+set -xe -o pipefail
+
+if [[ -e gerrit_comment.txt ]] ; then
+  echo
+  echo "posting review comment to gerrit..."
+  echo
+  cat gerrit_comment.txt
+  echo
+  ssh -p 29418 "$GERRIT_HOST" \
+      "gerrit review -p $GERRIT_PROJECT \
+       -m '$(cat gerrit_comment.txt)' \
+       $GERRIT_PATCHSET_REVISION \
+       --notify NONE"
+fi
index 090e915..0a05c4f 100644 (file)
@@ -10,7 +10,9 @@
 ##############################################################################
 echo "---> jjb-merge-job.sh"
 
+workers="${JJB_WORKERS:-0}"
+
 # Ensure we fail the job if any steps fail.
 set -eu -o pipefail
 
-jenkins-jobs update --recursive --delete-old --workers 4 jjb/
+jenkins-jobs update --recursive --delete-old --workers "$workers" jjb/
index 6b963a4..e0089c5 100644 (file)
@@ -18,7 +18,7 @@ REQUIREMENTS_FILE=$(mktemp /tmp/requirements-XXXX.txt)
 #       git+https://github.com/lfit/releng-lftools.git#egg=lftools[openstack]
 
 cat << EOF > "$REQUIREMENTS_FILE"
-lftools[openstack]~=0.21.0
+lftools[openstack]~=0.22.2
 python-heatclient~=1.16.1
 python-openstackclient~=3.16.0
 dogpile.cache~=0.6.8  # Version 0.7.[01] seems to break openstackclient
index f85e201..8484a71 100644 (file)
@@ -16,9 +16,7 @@ JAVA_ENV_FILE="/tmp/java.env"
 
 update-java-redhat() {
     if [[ "${SET_JDK_VERSION//[a-zA-Z]/}" = "11" ]]; then
-        export JAVA_HOME="/opt/jdk-11"
-    elif [[ "${SET_JDK_VERSION//[a-zA-Z]/}" = "10" ]]; then
-        export JAVA_HOME="/opt/jdk-10.0.2"
+        export JAVA_HOME="/usr/lib/jvm/java-11-openjdk"
     else
         export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION//[a-zA-Z:-]/}.0-openjdk"
     fi