From 40a8db919896289a6f4516378128a09adbce7a19 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Mon, 7 Aug 2017 09:59:48 +1000 Subject: [PATCH] Generalize deploy maven-file builder The builder hard codes the URL path which makes the builder limit deploy capabilites only to external nexus repos and not local file systems. The change fixes the above issue by allowing the calling job to define the repository path. ex: "${NEXUS_URL}/content/repositories/$REPO_ID" "file://$WORKSPACE/m2repo" Renamed variables: 'files-dir' to 'upload-files-dir' 'nexus-url-path' to 'maven-repo-url' '$NEXUS_URL_PATH' to '$MAVEN_REPO_URL' Change-Id: If0beb7f6dff76c18988c9a75b52c80358f16dff6 Signed-off-by: Anil Belur --- jjb/lf-macros.yaml | 3 ++- shell/deploy-maven-file.sh | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index 7d2cd983..10a332a7 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -132,9 +132,10 @@ settings-file: '{settings-file}' - inject: properties-content: | + MAVEN_REPO_URL={maven-repo-url} REPO_ID={repo-id} GROUP_ID={group-id} - UPLOAD_FILES_PATH={files-dir} + UPLOAD_FILES_PATH={upload-files-dir} - shell: !include-raw-escape: - ../shell/lftools-install.sh - ../shell/common-variables.sh diff --git a/shell/deploy-maven-file.sh b/shell/deploy-maven-file.sh index 37cfd9f4..dfb9a5aa 100644 --- a/shell/deploy-maven-file.sh +++ b/shell/deploy-maven-file.sh @@ -12,10 +12,18 @@ # This script publishes packages (rpms/debs) or any file to Nexus hosted # maven2 repository. # -# $NEXUS_URL : Jenkins global variable should be defined. +# $MAVEN_REPO_URL : Provided by a job parameter. +# The calling job can set $NEXUS_URL path or local +# directory to stage files. ex: +# -Durl="${NEXUS_URL}/content/repositories/$REPO_ID" +# -Durl="file://$WORKSPACE/m2repo" # $REPO_ID : Provided by a job parameter. +# A repository ID represents the repository. # $GROUP_ID : Provided by a job parameter. -# $UPLOAD_FILES_PATH : Provided by a job parameter. +# A group ID represents a nexus group. +# $UPLOAD_FILES_PATH : Provided by a job parameter. +# The directory contains one or more artifacts. + echo "---> deploy-maven-file.sh" # DO NOT enable -u because $MAVEN_PARAMS and $MAVEN_OPTIONS could be unbound. @@ -29,11 +37,9 @@ export MAVEN_PARAMS DEPLOY_LOG="$WORKSPACE/archives/deploy-maven-file.log" mkdir -p "$WORKSPACE/archives" -NEXUS_REPO_URL="${NEXUS_URL}/content/repositories/$REPO_ID" - while IFS="" read -r file do - lftools deploy maven-file "$NEXUS_REPO_URL" \ + lftools deploy maven-file "$MAVEN_REPO_URL" \ "$REPO_ID" \ "$file" \ -b "$MVN" \ -- 2.16.6