Merge "Add maven-deploy-file builder for packaging jobs" v0.4.0
authorAnil Shashikumar Belur <abelur@linuxfoundation.org>
Wed, 28 Jun 2017 07:22:22 +0000 (07:22 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Wed, 28 Jun 2017 07:22:22 +0000 (07:22 +0000)
jjb/lf-macros.yaml
shell/deploy-maven-file.sh [new file with mode: 0644]

index 3756473..cb37429 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 "*")