#!/bin/bash -e ########################################################################## # check mandatory parameters have been provided if [ -z "$PLUGIN_TOKEN" ] || [ -z "$PLUGIN_ARTIFACT" ] || \ [ -z "$PLUGIN_PACKAGE" ] || [ -z "$PLUGIN_VERSION" ] then echo 'token, artifact, package and version are mandatory settings' exit 1 fi # other optional parameters BASE_URL=${PLUGIN_URL:-https://git.burble.dn42/api/packages} USER=${PLUGIN_USER:-burble} OWNER=${PLUGIN_OWNER:-burble} FILENAME=${PLUGIN_FILENAME:-$PLUGIN_ARTIFACT} # version or token could be a filename function maybe_from_file { local var="$1" if [ -r "$var" ] then cat "$var" else echo "$var" fi } VERSION=$(maybe_from_file "$PLUGIN_VERSION") TOKEN=$(maybe_from_file "$PLUGIN_TOKEN") ########################################################################## # finally do the curl thing to upload the artifact url=$(printf '%s/%s/generic/%s/%s/%s' \ "$BASE_URL" "$OWNER" "$PLUGIN_PACKAGE" \ "$VERSION" "$PLUGIN_ARTIFACT") curl --user "${USER}:${TOKEN}" --upload-file="$FILENAME" "$url" ########################################################################## # end of file