Merge "Update cloud image Ubuntu18.04 mininet ovs"
[releng/builder.git] / jjb / releng-maven-mri-stage.sh
1 #!/bin/sh
2
3 echo "---> releng-maven-mri-stage.sh"
4 # This script publishes artifacts to a staging repo in Nexus and exports the karaf bundle URL.
5 #
6 # $WORKSPACE/m2repo   :  Exists and used to deploy the staging repository.
7 # $NEXUS_URL          :  Jenkins global variable should be defined.
8 # $STAGING_PROFILE_ID :  Provided by a job parameter.
9
10 # Ensure we fail the job if any steps fail.
11 set -xeu -o pipefail
12
13 TMP_FILE="$(mktemp)"
14 lftools deploy nexus-stage "$NEXUS_URL" "$STAGING_PROFILE_ID" "$WORKSPACE/m2repo" | tee "$TMP_FILE"
15 staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' "$TMP_FILE")
16
17 # Store repo info to a file in archives
18 mkdir -p "$WORKSPACE/archives"
19 echo "$staging_repo ${NEXUS_URL}/content/repositories/$staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
20
21 # TODO: remove the second xpath command once the old version in CentOS 7 is not used any more
22 staged_version=$(find . -name '*karaf*.pom' -exec \
23     sh -c 'xpath -e "/project/version/text()" "$1" 2>/dev/null || xpath "$1" "/project/version/text()" 2>/dev/null' xpath.sh {} \;)
24 BUNDLE_URL="${NEXUS_URL}/content/repositories/$staging_repo/org/opendaylight/${PROJECT}/${KARAF_ARTIFACT}/${staged_version}/${KARAF_ARTIFACT}-${staged_version}.zip"
25
26 # Cleanup
27 rm -f "$TMP_FILE"
28
29 echo "Bundle url is ${BUNDLE_URL}"
30
31 # Re-inject the new BUNDLE_URL for downstream jobs to pull from Nexus
32 cat > "${WORKSPACE}/maven-staged-bundle.env" <<EOF
33 BUNDLE_URL=${BUNDLE_URL}
34 KARAF_VERSION=${KARAF_VERSION}
35 EOF