#!/bin/bash # ============LICENSE_START======================================================= # Copyright (C) 2020 The Nordix Foundation. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # SPDX-License-Identifier: Apache-2.0 # ============LICENSE_END========================================================= set -o errexit set -o nounset set -o pipefail # Make directory to hold file artifacts (.war .jar etc) mkdir -p $ARTIFACT_DIRECTORY # Ensure at root of $WORKSPACE cd $WORKSPACE # For each file artifact create a reference in ARTIFACT_DIRECTORY # uses softlinks in order to save space and time # ARTIFACT_DIRECTORY contents will be pushed to Artifactory for ARTIFACT in $ARTIFACT_PATHS do # Check if file exists before creating a softlink if [ ! -f "$ARTIFACT" ]; then echo "$ARTIFACT does not exist." exit 1 fi echo "----------------------------------------------------" echo "Info: Copy $ARTIFACT into $ARTIFACT_DIRECTORY" echo "----------------------------------------------------" ln -sf $WORKSPACE/$ARTIFACT $ARTIFACT_DIRECTORY done cd $ARTIFACT_DIRECTORY # Rename the artifacts to include SHA commit ids of the projects for traceability # e.g. 6d3abef-d96bad4-catalog-be-1.6.1-SNAPSHOT.war for ARTIFACT in * do echo "----------------------------------------------------" echo "Info: Adding CommitIDs $COMMIT_IDS to $ARTIFACT filename" echo "----------------------------------------------------" mv "$ARTIFACT" "$COMMIT_IDS-$ARTIFACT" done