-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·49 lines (40 loc) · 1.42 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·49 lines (40 loc) · 1.42 KB
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
44
45
46
47
48
49
#!/bin/bash
# Deploy MarkdownX plugin to Bitbucket Data Center via UPM REST API.
#
# Usage: ./deploy.sh [BITBUCKET_URL] [USERNAME] [PASSWORD]
# BITBUCKET_URL — base URL, default http://localhost:7990
# USERNAME — admin username, default admin
# PASSWORD — admin password, default admin
#
# Requires target/markdown-extra-*.jar (run `mvn package -DskipTests` first).
BITBUCKET_URL="${1:-http://localhost:7990}"
USERNAME="${2:-admin}"
PASSWORD="${3:-admin}"
PLUGIN_JAR=$(ls -t target/markdown-extra-*.jar 2>/dev/null | head -1)
if [ -z "$PLUGIN_JAR" ]; then
echo "ERROR: No JAR found in target/. Run 'mvn package' first."
exit 1
fi
echo "Deploying $PLUGIN_JAR to $BITBUCKET_URL..."
# Get UPM token
TOKEN=$(curl -s -u "$USERNAME:$PASSWORD" \
"$BITBUCKET_URL/rest/plugins/1.0/?os_authType=basic" \
-I 2>/dev/null | grep -i 'upm-token' | sed 's/.*: //' | tr -d '\r\n')
if [ -z "$TOKEN" ]; then
echo "ERROR: Could not obtain UPM token. Check credentials."
exit 1
fi
# Upload plugin
RESPONSE=$(curl -s -w "\n%{http_code}" \
-u "$USERNAME:$PASSWORD" \
-F "plugin=@$PLUGIN_JAR" \
"$BITBUCKET_URL/rest/plugins/1.0/?token=$TOKEN")
HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -n -1)
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
echo "SUCCESS: Plugin deployed (HTTP $HTTP_CODE)"
else
echo "FAILED: HTTP $HTTP_CODE"
echo "$BODY"
exit 1
fi