--- /dev/null
+******
+Deploy
+******
+
+.. program-output:: lftools deploy --help
+
+Commands
+========
+
+.. contents:: Deploy Commands
+ :local:
+
+archives
+--------
+
+.. program-output:: lftools deploy archives --help
+
+logs
+----
+
+.. program-output:: lftools deploy logs --help
+
+nexus
+-----
+
+.. program-output:: lftools deploy nexus --help
sys.exit(status)
+@click.command()
+@click.argument('nexus-repo-url', envvar='NEXUS_REPO_URL')
+@click.argument('deploy-dir', envvar='DEPLOY_DIR')
+@click.pass_context
+def nexus(ctx, nexus_repo_url, deploy_dir):
+ """Deploy a Maven repository to a specified Nexus repository.
+
+ This script takes a local Maven repository and deploys it to a Nexus
+ repository.
+
+ Example Repository:
+
+ https://nexus.example.org/content/repositories/release
+ """
+ status = subprocess.call(['deploy', 'nexus', nexus_repo_url, deploy_dir])
+ sys.exit(status)
+
+
deploy.add_command(archives)
deploy.add_command(logs)
+deploy.add_command(nexus)
deploy_logs "$@"
exit 0
;;
+ nexus )
+ echo "Deploying Maven artifacts..."
+ deploy_nexus "$@"
+ exit 0
+ ;;
+ nexus-stage )
+ echo "Deploying Maven artifacts to staging repo..."
+ deploy_nexus_stage "$@"
+ exit 0
+ ;;
* )
echo "Invalid command: $subcommand" 1>&2
exit 1
rm -rf "$tmpdir"
}
+deploy_nexus() {
+ # Deploy Maven artifacts to Nexus using curl
+ #
+ # Parameters:
+ #
+ # nexus_repo_url: The URL to the Nexus repo.
+ # (Ex: https://nexus.example.org/content/repositories/release)
+ # deploy_dir: The path to a directory to deploy. (Ex: /tmp/m2repo)
+ #
+ # One purpose of this is so that we can get around the problematic
+ # deploy-at-end configuration with upstream Maven.
+ # https://issues.apache.org/jira/browse/MDEPLOY-193
+
+ local nexus_repo_url="$1"
+ local deploy_dir="$2"
+
+ if [ -z "$2" ]; then
+ echo "Missing required arguments."
+ echo "Usage: deploy nexus <nexus_repo_url> <deploy_dir>"
+ exit 1
+ fi
+
+ pushd "$deploy_dir"
+ file_list=($(find . -type f \
+ ! -name "maven-metadata*" \
+ ! -name _remote.repositories \
+ ! -name resolver-status.properties \
+ | cut -c 3-))
+
+ for file in "${file_list[@]}"; do
+ echo "Uploading ${file}"
+
+ local resp
+ resp=$(curl -s -w "%{http_code}" --netrc --upload-file "$file" "$nexus_repo_url/$file")
+ status=$(echo "$resp" | awk 'END {print $NF}')
+
+ if [ "$status" != "201" ]; then
+ echo "ERROR: Failed to upload to Nexus. Aborting..."
+ echo "$resp"
+ exit "$status"
+ fi
+ done
+ popd
+}
+
# Only run the script if it is being called directly and not sourced.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then