Chore: Upgrade Jenkins-job-builder to 6.3.0
[releng/global-jjb.git] / shell / maven-stage.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> maven-stage.sh"
12 # This script publishes artifacts to a staging repo in Nexus.
13 #
14 # $WORKSPACE/m2repo   :  Exists and used to deploy the staging repository.
15 # $NEXUS_URL          :  Jenkins global variable should be defined.
16 # $STAGING_PROFILE_ID :  Provided by a job parameter.
17
18 # Ensure we fail the job if any steps fail.
19 set -xeu -o pipefail
20
21 # shellcheck disable=SC1090
22 . ~/lf-env.sh
23
24 lf-activate-venv --python python3 lftools
25
26 TMP_FILE="$(mktemp)"
27 lftools deploy nexus-stage "$NEXUS_URL" "$STAGING_PROFILE_ID" "$WORKSPACE/m2repo" | tee "$TMP_FILE"
28 staging_repo=$(sed -n -e 's/Staging repository \(.*\) created\./\1/p' "$TMP_FILE")
29
30 # Store repo info to a file in archives
31 mkdir -p "$WORKSPACE/archives"
32 echo "$staging_repo ${NEXUS_URL}/content/repositories/$staging_repo" | tee -a "$WORKSPACE/archives/staging-repo.txt"
33
34 # Cleanup
35 rm -f "$TMP_FILE"