-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnexusScripter.sh
40 lines (32 loc) · 1.32 KB
/
nexusScripter.sh
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
#to store the pwd outside of git
#export NEXUS_PWD=admin123
source pwd.sh
export NEXUS_HOST="artifact.scaling.ch"
export NEXUS_URL="https://$NEXUS_HOST"
export NEXUS_USER=admin
export NEXUS_SCRIPTING_PATH="$NEXUS_URL/service/siesta/rest/v1/script"
# fail if anything errors
set -e
# fail if a function call is missing an argument
set -u
function nxlistscripts {
curl -v -u $NEXUS_USER:$NEXUS_PWD $NEXUS_SCRIPTING_PATH
}
function nxrunscript {
name=$1
curl -v -X POST -u $NEXUS_USER:$NEXUS_PWD --header "Content-Type: text/plain" "$NEXUS_SCRIPTING_PATH/$name/run"
}
function nxrunscriptjarg {
name=$1
jsonargs=$2
curl -v -X POST -u $NEXUS_USER:$NEXUS_PWD --header "Content-Type: text/plain" -d $jsonargs "$NEXUS_SCRIPTING_PATH/$name/run"
}
# add a script to the repository manager and run it
function nxaddscript {
name=$1
file=$2
# using grape config that points to local Maven repo and Central Repository , default grape config fails on some downloads although artifacts are in Central
# change the grapeConfig file to point to your repository manager, if you are already running one in your organization
groovy -Dgroovy.grape.report.downloads=true -Dgrape.config=grapeConfig.xml addUpdatescript.groovy -u "$NEXUS_USER" -p "$NEXUS_PWD" -n "$name" -f "$file" -h "$NEXUS_URL"
printf "\nPublished $file as $name\n\n"
}