--- /dev/null
+---
+- project:
+ name: example-sonarcloud
+ jobs:
+ - gerrit-maven-sonar
+
+ project: 'sonarcloud'
+ project-name: 'sonarcloud'
+ branch: 'master'
+ mvn-settings: 'sonarcloud-settings'
+ mvn-opts: '-Xmx1024m'
+ sonarcloud: true
+ sonarcloud-project-key: KEY
+ sonarcloud-project-organization: ORGANIZATION
+ sonarcloud-api-token: TOKEN
:mvn-version: Version of Maven to execute Sonar with.
:mvn-settings: Maven settings.xml file containing credentials to use.
+lf-infra-maven-sonarcloud
+-------------------------
+
+Runs Sonar against a Maven project and pushes results to SonarCloud.
+
+:Required Parameters:
+
+ :java-version: Version of Java to execute Sonar with.
+ :mvn-version: Version of Maven to execute Sonar with.
+ :mvn-settings: Maven settings.xml file containing credentials to use.
+ :sonarcloud-project-key: SonarCloud project key.
+ :sonarcloud-project-organization: SonarCloud project organization.
+ :sonarcloud-api-token: SonarCloud API Token.
+
lf-maven-build
--------------
:gerrit_release_triggers: Override Gerrit Triggers.
+.. _maven-sonar:
+
Maven Sonar
-----------
: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)
+ :sonar-mvn-goals: Maven goals to run for sonar analysis.
+ (default: sonar:sonar)
+ :sonarcloud: Whether or not to use SonarCloud ``true|false``.
+ (default: false)
+ :sonarcloud-project-key: SonarCloud project key. (default: '')
+ :sonarcloud-project-organization: SonarCloud project organization.
+ (default: '')
+ :sonarcloud-api-token: SonarCloud API Token. (default: '')
:stream: Keyword that can be used to represent a release code-name.
Often the same as the branch. (default: master)
:submodule-recursive: Whether to checkout submodules recursively.
:gerrit_sonar_triggers: Override Gerrit Triggers.
+
+SonarCloud Example:
+
+.. literalinclude:: ../../.jjb-test/lf-maven-jobs/maven-sonarcloud.yaml
+ :language: yaml
+
Maven Verify
------------
--- /dev/null
+---
+Job Templates
+=============
+
+.. _release-announce:
+
+Release Announce
+----------------
+
+Job for lf-releng projects to automate release announcement emails.
+
+:Template Names:
+ - {project-name}-release-announce
+ - gerrit-release-announce
+
+:Required parameters:
+
+ :build-node: The node to run build on.
+ :jenkins-ssh-credential: Credential to use for SSH. (Configured in
+ defaults.yaml)
condition-kind: boolean-expression
condition-expression: '{mvn-central}'
steps:
+ - lf-provide-maven-settings:
+ global-settings-file: '{mvn-global-settings}'
+ settings-file: '{mvn-settings}'
- lf-infra-create-netrc:
server-id: 'ossrh'
- inject:
properties-content: 'OSSRH_PROFILE_ID={ossrh-profile-id}'
- shell: !include-raw-escape: ../shell/maven-central.sh
+ - lf-provide-maven-settings-cleanup
- builder:
name: lf-maven-install
- builder:
name: lf-maven-stage
builders:
+ - lf-provide-maven-settings:
+ global-settings-file: '{mvn-global-settings}'
+ settings-file: '{mvn-settings}'
+ - lf-infra-create-netrc:
+ server-id: '{mvn-staging-id}'
# include-raw-escape fails due to JJB bug
- - shell: !include-raw:
+ - shell: !include-raw-escape:
- ../shell/common-variables.sh
- ../shell/maven-stage.sh
+ - lf-provide-maven-settings-cleanup
- builder:
name: lf-update-java-alternatives
- lf-provide-maven-settings:
global-settings-file: '{mvn-global-settings}'
settings-file: '{mvn-settings}'
- - lf-infra-create-netrc:
- server-id: '{mvn-staging-id}'
- shell: !include-raw-escape: ../shell/maven-patch-release.sh
- lf-maven-build:
mvn-goals: '{mvn-goals}'
- lf-sigul-sign-dir:
sign-artifacts: '{sign-artifacts}'
sign-dir: '$WORKSPACE/m2repo'
- - lf-maven-stage
+ - lf-maven-stage:
+ mvn-global-settings: '{mvn-global-settings}'
+ mvn-settings: '{mvn-settings}'
+ mvn-staging-id: '{mvn-staging-id}'
- lf-maven-central:
mvn-central: '{mvn-central}'
+ mvn-global-settings: '{mvn-global-settings}'
+ mvn-settings: '{mvn-settings}'
ossrh-profile-id: '{ossrh-profile-id}'
- lf-provide-maven-settings-cleanup
mvn-params: ''
mvn-version: mvn35
sonar-mvn-goal: 'sonar:sonar'
+ sonarcloud: false
+ sonarcloud-project-key: ''
+ sonarcloud-project-organization: ''
+ sonarcloud-api-token: ''
stream: master
submodule-recursive: true
submodule-timeout: 10
builders:
- lf-infra-pre-build
- - lf-infra-maven-sonar:
- java-version: '{java-version}'
- mvn-settings: '{mvn-settings}'
- mvn-version: '{mvn-version}'
+ # With SonarCloud
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: '{sonarcloud}'
+ steps:
+ - shell: echo 'Using SonarCloud'
+ - lf-infra-maven-sonarcloud:
+ java-version: '{java-version}'
+ mvn-settings: '{mvn-settings}'
+ mvn-version: '{mvn-version}'
+ sonarcloud-project-key: '{sonarcloud-project-key}'
+ sonarcloud-project-organization: '{sonarcloud-project-organization}'
+ sonarcloud-api-token: '{sonarcloud-api-token}'
+ # With SonarQube
+ - conditional-step:
+ condition-kind: not
+ condition-operand:
+ condition-kind: boolean-expression
+ condition-expression: '{sonarcloud}'
+ steps:
+ - shell: echo 'Using SonarQube'
+ - lf-infra-maven-sonar:
+ java-version: '{java-version}'
+ mvn-settings: '{mvn-settings}'
+ mvn-version: '{mvn-version}'
publishers:
- lf-jacoco-report
- ../shell/maven-sonar.sh
- lf-provide-maven-settings-cleanup
+- builder:
+ name: lf-infra-maven-sonarcloud
+ # Run a Sonar build with Maven
+ builders:
+ - lf-maven-install:
+ mvn-version: '{mvn-version}'
+ - lf-update-java-alternatives:
+ java-version: '{java-version}'
+ - inject:
+ # Switch this to the sonar wrapper when JJB 2.0 is available
+ properties-content: |
+ SONAR_HOST_URL=https://sonarcloud.io
+ PROJECT_KEY={sonarcloud-project-key}
+ PROJECT_ORGANIZATION={sonarcloud-project-organization}
+ API_TOKEN={sonarcloud-api-token}
+ - lf-provide-maven-settings:
+ global-settings-file: global-settings
+ settings-file: '{mvn-settings}'
+ - shell: !include-raw-escape:
+ - ../shell/common-variables.sh
+ - ../shell/maven-sonar.sh
+ - lf-provide-maven-settings-cleanup
+
- job-template:
name: '{project-name}-sonar'
id: gerrit-maven-sonar
--- /dev/null
+---
+####################
+# Release Announce #
+####################
+
+- lf_release_announce: &lf_release_announce
+ name: lf-release-announce
+
+ ######################
+ # Default parameters #
+ ######################
+
+ build-days-to-keep: 7
+ build-timeout: 15
+ disable-job: false
+
+ #####################
+ # Job Configuration #
+ #####################
+
+ project-type: freestyle
+ node: '{build-node}'
+ disabled: '{disable-job}'
+
+ properties:
+ - lf-infra-properties:
+ build-days-to-keep: '{build-days-to-keep}'
+
+ builders:
+ - shell: !include-raw-escape: ../shell/release-announce.sh
+
+ wrappers:
+ - lf-infra-wrappers:
+ build-timeout: '{build-timeout}'
+ jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+ publishers:
+ - lf-infra-publish
+
+
+- job-template:
+ name: '{project-name}-release-announce'
+ id: gerrit-release-announce
+ <<: *lf_release_announce
+
+ triggers:
+ - gerrit:
+ server-name: '{gerrit-server-name}'
+ trigger-on:
+ - ref-updated-event
+ projects:
+ - project-compare-type: 'ANT'
+ project-pattern: '{project-pattern}'
+ branches:
+ - branch-compare-type: 'ANT'
+ branch-pattern: 'refs/tags/**'
--- /dev/null
+---
+features:
+ - |
+ New job-template **{project-name}-release-announce** for lf-releng projects
+ to automate release announcement emails.
--- /dev/null
+---
+upgrade:
+ - |
+ Jobs using the **lf-maven-stage** macro now need to update to the new
+ usage. Preparation calls to **lf-provide-maven-settings**,
+ **lf-infra-create-netrc**, and **lf-provide-maven-settings-cleanup** are no
+ longer necessary to prepare the **lf-maven-stage** macro.
+
+ Usage:
+
+ .. code-block:: yaml
+
+ - lf-maven-stage:
+ mvn-global-settings: 'global-settings'
+ mvn-settings: 'settings'
+ mvn-staging-id: 'staging profile id'
--- /dev/null
+---
+features:
+ - |
+ Add support for pushing Sonar results to SonarCloud. Refer to
+ :ref:`Maven Sonar docs <maven-sonar>` for details.
export MAVEN_OPTS
+declare -a params
+params+=("--global-settings $GLOBAL_SETTINGS_FILE")
+params+=("--settings $SETTINGS_FILE")
+
# Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
# shellcheck disable=SC2086
$MVN clean install \
-e -Dsonar \
- --global-settings "$GLOBAL_SETTINGS_FILE" \
- --settings "$SETTINGS_FILE" \
+ ${params[*]} \
$MAVEN_OPTIONS $MAVEN_PARAMS
+if [ "$SONAR_HOST_URL" = "https://sonarcloud.io" ]; then
+ params+=("-Dsonar.projectKey=$PROJECT_KEY")
+ params+=("-Dsonar.organization=$PROJECT_ORGANIZATION")
+ params+=("-Dsonar.login=$API_TOKEN")
+fi
+
# Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
# shellcheck disable=SC2086
-$MVN $SONAR_MAVEN_GOAL \
+"$MVN" $SONAR_MAVEN_GOAL \
-e -Dsonar -Dsonar.host.url="$SONAR_HOST_URL" \
- --global-settings "$GLOBAL_SETTINGS_FILE" \
- --settings "$SETTINGS_FILE" \
+ ${params[*]} \
$MAVEN_OPTIONS $MAVEN_PARAMS
set -eu -o pipefail
-declare -a images
-declare -a cfg_images
-declare -a yaml_images
-readarray -t cfg_images <<< "$(grep -r IMAGE_NAME --include \*.cfg \
- | awk -F'=' '{print $2}' | sort -u)"
-readarray -t yaml_images <<< "$(grep -r 'ZZCI - ' --include \*.yaml \
- | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" | sort -u)"
-mapfile -t images < <(for R in "${cfg_images[@]}" "${yaml_images[@]}" ; do echo "$R" ; done | sort -u)
-
+conf_images=("$(grep -r IMAGE_NAME --include \*.cfg jenkins-config \
+ | awk -F'=' '{print $2}' | sort -u)")
+# If there are no yaml files the 'grep' will fail, which is OK
+yaml_images=("$(grep -r 'ZZCI - ' --include \*.yaml jjb \
+ | awk -F": " '{print $3}' | sed "s:'::;s:'$::;/^$/d" \
+ | sort -u)") || true
+readarray -t images <<< "$(for i in "${conf_images[@}" "${yaml_images[@]}"; do \
+ echo "$i"; done | sort)"
for image in "${images[@]}"; do
+ [[ -z $image ]] && continue
os_image_protected=$(openstack --os-cloud "$os_cloud" \
image show "$image" -f value -c protected)
echo "Protected setting for $image: $os_image_protected"
-#!/bin/bash
+#!/bin/bash -ue
# SPDX-License-Identifier: EPL-1.0
##############################################################################
# Copyright (c) 2017 The Linux Foundation and others.
##############################################################################
echo "---> packer-clear-credentials.sh"
-set +e # DO NOT cause build failure if any of the rm calls fail.
-rm "$CLOUDENV"
-exit 0
+# OK if $CLOUDENV does not exist or empty
+# Fails if $CLOUDENV exists and rm is unable to delete it
+rm -rf "$CLOUDENV"
# git+https://github.com/lfit/releng-lftools.git#egg=lftools[openstack]
cat << EOF > "$REQUIREMENTS_FILE"
-lftools[openstack]~=0.18.0
+lftools[openstack]~=0.20.0
python-heatclient~=1.16.1
python-openstackclient~=3.16.0
dogpile.cache~=0.6.8 # Version 0.7.[01] seems to break openstackclient
+niet~=1.4.2 # Extract values from yaml
EOF
echo "Requirements file"
--- /dev/null
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 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
+##############################################################################
+
+PROJECT="${GERRIT_PROJECT#releng/}" # For releng projects strip the prefix
+TAG_NAME="${GERRIT_REFNAME#refs/tags/}"
+
+set -eux -o pipefail
+
+mail_opts=()
+mail_opts+=("-r" "LF Releng <lf-releng@lists.linuxfoundation.org>")
+mail_opts+=("-s" "$PROJECT $TAG_NAME released")
+mail_opts+=("lf-releng@lists.linuxfoundation.org")
+
+mail "${mail_opts[@]}" << EOF
+Hi Everyone,
+
+$PROJECT $TAG_NAME is released. Thanks to everyone who contributed
+to this release. Release notes are available online at:
+
+https://docs.releng.linuxfoundation.org/projects/$PROJECT/en/latest/release-notes.html#${TAG_NAME}
+
+Cheers,
+LF Releng
+EOF