Merge "Pass common maven options to deploy file builder"
[releng/global-jjb.git] / shell / deploy-maven-file.sh
1 #!/bin/bash
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
12 # This script publishes packages (rpms/debs) or any file to Nexus hosted
13 # maven2 repository.
14 #
15 # $NEXUS_URL          :  Jenkins global variable should be defined.
16 # $REPO_ID            :  Provided by a job parameter.
17 # $GROUP_ID           :  Provided by a job parameter.
18 # $UPLOAD_FILES_PATH  :  Provided by a job parameter.
19 echo "---> deploy-maven-file.sh"
20
21 # DO NOT enable -u because $MAVEN_PARAMS and $MAVEN_OPTIONS could be unbound.
22 # Ensure we fail the job if any steps fail.
23 set -e -o pipefail
24 set +u
25
26 export MAVEN_OPTIONS
27 export MAVEN_PARAMS
28
29 DEPLOY_LOG="$WORKSPACE/archives/deploy-maven-file.log"
30 mkdir -p "$WORKSPACE/archives"
31
32 NEXUS_REPO_URL="${NEXUS_URL}/content/repositories/$REPO_ID"
33
34 while IFS="" read -r file
35 do
36     lftools deploy maven-file "$NEXUS_REPO_URL" \
37                               "$REPO_ID" \
38                               "$file" \
39                               -b "$MVN" \
40                               -g "$GROUP_ID" \
41                               -p "$MAVEN_PARAMS $MAVEN_OPTIONS" \
42                               |& tee "$DEPLOY_LOG"
43 done < <(find "$UPLOAD_FILES_PATH" -type f -name "*")