Add mri-stage job
[releng/builder.git] / jjb / releng-maven-mri-stage.sh
1 #!/bin/bash
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 staged_version=$(find . -name '*karaf*.pom' -exec xpath -q -e '/project/version/text()' {} +)
22 BUNDLE_URL="${NEXUS_URL}/content/repositories/$staging_repo/org/opendaylight/${PROJECT}/${KARAF_ARTIFACT}/${staged_version}/${KARAF_ARTIFACT}-${staged_version}.zip"
23
24 # Cleanup
25 rm -f "$TMP_FILE"
26
27 echo "Bundle url is ${BUNDLE_URL}"
28
29 # Re-inject the new BUNDLE_URL for downstream jobs to pull from Nexus
30 cat > "${WORKSPACE}/maven-staged-bundle.env" <<EOF
31 BUNDLE_URL=${BUNDLE_URL}
32 KARAF_VERSION=${KARAF_VERSION}
33 EOF