From: Anil Belur Date: Wed, 14 Jun 2017 08:12:40 +0000 (+1000) Subject: Add maven-deploy-file builder for packaging jobs X-Git-Tag: v0.4.0^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F5200%2F24;p=releng%2Fglobal-jjb.git Add maven-deploy-file builder for packaging jobs Change-Id: I243d13c257756f653b702c57e5d8c700411c53e9 Signed-off-by: Anil Belur --- diff --git a/jjb/lf-macros.yaml b/jjb/lf-macros.yaml index c2b3f2d8..4081f775 100644 --- a/jjb/lf-macros.yaml +++ b/jjb/lf-macros.yaml @@ -54,6 +54,30 @@ 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 @@ -76,6 +100,7 @@ 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 index 00000000..ac6a4389 --- /dev/null +++ b/shell/deploy-maven-file.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# @License 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 "*")