-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.sh
More file actions
executable file
·33 lines (28 loc) · 879 Bytes
/
upload.sh
File metadata and controls
executable file
·33 lines (28 loc) · 879 Bytes
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
#!/bin/sh
# upload.sh - file uploader for Bitbucket Cloud
# Copyright (C) 2018-2019 Kaz Nishimura
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.
repository="$BITBUCKET_REPO_FULL_NAME"
user="$USERNAME${PASSWORD+:$PASSWORD}"
while getopts 'r:u:' opt; do
case "$opt" in
r) repository="$OPTARG" ;;
u) user="$OPTARG" ;;
'?') exit 64 ;;
esac
done
set -- _ "$@"
shift "$OPTIND"
if test -z "$repository"; then
echo "$0: repository not specified" >&2
exit 1
fi
args=
for file in "$@"; do
args="$args --fail --form files=@\"$file\""
done
exec curl ${user:+--user "$user"} --request POST $args \
"https://api.bitbucket.org/2.0/repositories/$repository/downloads"