Add maven-deploy-file builder for packaging jobs 00/5200/24
authorAnil Belur <abelur@linuxfoundation.org>
Wed, 14 Jun 2017 08:12:40 +0000 (18:12 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Tue, 27 Jun 2017 21:22:09 +0000 (07:22 +1000)
Change-Id: I243d13c257756f653b702c57e5d8c700411c53e9
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
jjb/lf-macros.yaml
shell/deploy-maven-file.sh [new file with mode: 0644]

index c2b3f2d..4081f77 100644 (file)
     builders:
       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
 
+- builder:
+    name: lf-infra-deploy-maven-file
+    # Deploy files to a repository.
+    #
+    # The builder requires passing the following parameters
+    # REPO_ID:           Repository ID
+    # GROUP_ID:          Group ID of the repository
+    # UPLOAD_FILES_PATH: Path to directory containing one or more files
+    builders:
+      - lf-maven-install:
+          mvn-version: '{mvn-version}'
+      - lf-provide-maven-settings:
+          global-settings-file: '{global-settings-file}'
+          settings-file: '{settings-file}'
+      - inject:
+          properties-content: |
+              REPO_ID={repo-id}
+              GROUP_ID={group-id}
+              UPLOAD_FILES_PATH={files-dir}
+      - shell: !include-raw-escape:
+          - ../shell/lftools-install.sh
+          - ../shell/deploy-maven-file.sh
+      - lf-provide-maven-settings-cleanup
+
 - builder:
     name: lf-maven-install
     # call maven-target builder with a goal of --version to force Jenkins to
               variable: 'GLOBAL_SETTINGS_FILE'
             - file-id: '{settings-file}'
               variable: 'SETTINGS_FILE'
+
 - builder:
     name: lf-provide-maven-settings-cleanup
     # Clear maven settings files after we are done using them
diff --git a/shell/deploy-maven-file.sh b/shell/deploy-maven-file.sh
new file mode 100644 (file)
index 0000000..ac6a438
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# This script publishes packages (rpms/debs) or any file to Nexus hosted
+# maven2 repository.
+#
+# $NEXUS_URL          :  Jenkins global variable should be defined.
+# $REPO_ID            :  Provided by a job parameter.
+# $GROUP_ID           :  Provided by a job parameter.
+# $UPLOAD_FILES_PATH  :  Provided by a job parameter.
+echo "---> deploy-maven-file.sh"
+# Ensure we fail the job if any steps fail.
+set -eu -o pipefail
+
+DEPLOY_LOG="$WORKSPACE/archives/deploy-maven-file.log"
+mkdir -p "$WORKSPACE/archives"
+
+NEXUS_REPO_URL="${NEXUS_URL}/$REPO_ID"
+mkdir -p "$UPLOAD_FILES_PATH"
+
+while IFS="" read -r file
+do
+    lftools deploy maven-file "$NEXUS_REPO_URL" \
+                              "$REPO_ID" \
+                              "$file" \
+                              -b "$MVN" \
+                              -g "$GROUP_ID" | tee "$DEPLOY_LOG"
+done < <(find "$UPLOAD_FILES_PATH" -type d -name "*")