:build-timeout: Timeout in minutes before aborting build. (default: 60)
:git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
:java-version: Version of Java to use for the build. (default: openjdk8)
+ :mvn-central: Set to 'true' to also stage to OSSRH. This is for projects
+ that want to release to Maven Central. If set the parameter
+ ``ossrh-profile-id`` also needs to be set. (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: '')
For example 'odl-'. (default: '')
:nexus-iq-stage: Stage the policy evaluation will be run against on
the Nexus IQ Server. (default: 'build')
+ :ossrh-profile-id: Profile ID for project as provided by OSSRH.
+ (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.
git-url: '$GIT_URL/$PROJECT'
github-url: 'https://github.com'
java-version: openjdk8
+ mvn-central: false
mvn-global-settings: global-settings
mvn-goals: clean deploy
mvn-opts: ''
mvn-params: ''
mvn-version: mvn35
+ ossrh-profile-id: ''
sign-artifacts: false
stream: master
submodule-recursive: true
sign-artifacts: '{sign-artifacts}'
sign-dir: '$WORKSPACE/m2repo'
- lf-maven-stage
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: '{mvn-central}'
+ steps:
+ - 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
- job-template:
--- /dev/null
+---
+features:
+ - |
+ Add support to maven-stage jobs to publish to Maven Central via OSSRH.
+
+ This is accomplished by adding these 2 new optional parameters to the job
+ configuration.
+
+ .. code-block:: yaml
+
+ - gerrit-maven-stage:
+ mvn-central: true
+ ossrh-profile-id: 7edbe315063867
if [ -z "$CREDENTIAL" ] && [ "$SERVER_ID" == "logs" ]; then
echo "WARN: Log server credential not found."
exit 0
+elif [ -z "$CREDENTIAL" ] && [ "$SERVER_ID" == "ossrh" ]; then
+ echo "WARN: OSSRH credentials not found."
+ echo " This is needed for staging to Maven Central."
+ exit 0
elif [ -z "$CREDENTIAL" ]; then
echo "ERROR: Credential not found."
exit 1
fi
-machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
+if [ "$SERVER_ID" == "ossrh" ]; then
+ machine="oss.sonatype.org"
+else
+ machine=$(echo "$NEXUS_URL" | awk -F/ '{print $3}')
+fi
+
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
+echo "machine ${machine%:*} login $user password $pass" >> ~/.netrc
--- /dev/null
+#!/bin/bash -l
+# 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
+##############################################################################
+
+profile_id="${OSSRH_PROFILE_ID:-}"
+
+# Ensure we fail the job if any steps fail.
+set -eux -o pipefail
+
+MC_TMP_FILE="$(mktemp)"
+echo "Staging in OSSRH for Maven Central"
+lftools deploy nexus-stage "https://oss.sonatype.org" "$profile_id" "$WORKSPACE/m2repo" | tee "$MC_TMP_FILE"
+mc_staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' "$MC_TMP_FILE")
+rm -f "$MC_TMP_FILE"
+
+echo "$mc_staging_repo https://oss.sonatype.org/content/repositories/$mc_staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
# Store repo info to a file in archives
mkdir -p "$WORKSPACE/archives"
-echo "$staging_repo" > "$WORKSPACE/archives/staging-repo.txt"
+echo "$staging_repo ${NEXUS_URL}/content/repositories/$staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
# Cleanup
rm -f "$TMP_FILE"