Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to upload plugins #52

Merged
merged 1 commit into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ work
.settings/
.bin/
.factorypath
.project
.project

# private files
env.sh
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
install:
mvn clean install -DskipTests

package:
mvn clean package -DskipTests

upload:
./upload.sh

pu: package upload

clean:
rm -rf target
23 changes: 23 additions & 0 deletions upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
# current script needs env.sh to setup some environment variables
# use python to parse json result

target_file=target/localization-zh-cn.hpi

if [ ! -f "$(dirname "${BASH_SOURCE[0]}")/env.sh" ]; then
echo 'we need the env.sh to setup vars'
exit -1
fi

source $(dirname "${BASH_SOURCE[0]}")/env.sh

issuer=$(curl -u admin:$JENKINS_TOKEN $JENKINS_URL/crumbIssuer/api/json -s -o /dev/null -w %{http_code})
if [ "$issuer" == "200" ]; then
export issuer=$(curl -u admin:$JENKINS_TOKEN $JENKINS_URL/crumbIssuer/api/json -s)
issuer=$(python -c "import json;import os;issuer=os.getenv('issuer');issuer=json.loads(issuer);print issuer['crumb']")
else
issuer=""
fi

curl -u admin:$JENKINS_TOKEN $JENKINS_URL/pluginManager/uploadPlugin -F "name=@$(dirname "${BASH_SOURCE[0]}")/$target_file" --header "Jenkins-Crumb: $issuer"
curl -u admin:$JENKINS_TOKEN $JENKINS_URL/restart -X POST --header "Jenkins-Crumb: $issuer"