1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/bin/bash
set -xe
usage(){
echo "Usage: $0 [option]" >&2
echo
echo " -h, --help show this help"
echo " -u, --username username for basic authentication"
echo " -p, --password password for basic authentication"
echo " -H, --baseurl URL of Nexus instance "
echo " -r, --reponame name of the repository where to put artifacts "
echo " -d, --directory name of the source directorty containing the artifacts "
echo
}
while getopts ":hu:p:H:r:d:" opt; do
case $opt in
h | --help) usage; exit 0 >&2;;
u | --username) username=$OPTARG;;
p | --password) password=$OPTARG;;
H | --baseurl) baseurl=$OPTARG;;
r | --reponame) reponame=$OPTARG;;
d | --directory) directory=$OPTARG;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
dirname=`basename ${directory}`
parentdir=`dirname ${directory}`
cd ${parentdir}
for file in `find ${dirname} -type f`; do
result=`curl -s -I --user ${username}:${password} --upload-file ${file} ${baseurl}/repository/${reponame}/${file} | head -n1`
echo "${file} -> ${result}"
done
|