grim/convey
Clone
Summary
Browse
Changes
Graph
Merged in efritz/convey/env-loop (pull request #21)
2017-09-26, Gary Kramlich
47c2851788ff
file is
Executable
Merged in efritz/convey/env-loop (pull request #21)
Fix infinite env mapping loop
Fixes #124
#!/bin/sh
set
-e
if
[
-z
"
${
BITBUCKET_REPO
}
"
]
;
then
echo
"you must specify a BITBUCKET_REPO"
>
&
2
exit
1
fi
if
[
-z
"
${
BITBUCKET_AUTH_USER
}
"
]
;
then
echo
"BITBUCKET_AUTH_USER not set. You must specify a user to authenticate as"
exit
1
fi
if
[
-z
"
${
BITBUCKET_AUTH_PASSWORD
}
"
]
;
then
echo
"BITBUCKET_AUTH_PASSWORD not set."
exit
1
fi
BITBUCKET_HOST
=
"
${
BITBUCKET_HOST
:-
api
.bitbucket.org
}
"
BITBUCKET_ROOT_URL
=
"
${
BITBUCKET_URL
:-
https
://
${
BITBUCKET_HOST
}
/2.0/
}
"
BITBUCKET_ROOT_URL
=
$(
echo
${
BITBUCKET_ROOT_URL
}
|
sed
's@/*$@@'
)
BITBUCKET_REPO
=
$(
echo
${
BITBUCKET_REPO
}
|
sed
's@^/*@@'
|
sed
's@/*$@@'
)
cd
${
CONVEY_WORKSPACE
}
FILE_ARGS
=
""
for
FILE_NAME
in
${
BITBUCKET_FILES
}
;
do
FILE_ARGS
=
"
${
FILE_ARGS
}
-F files=@\"
${
FILE_NAME
}
\""
done
set
+x
printf
"machine
${
BITBUCKET_HOST
}
login
${
BITBUCKET_AUTH_USER
}
password
${
BITBUCKET_AUTH_PASSWORD
}
"
|
\
(
set
-x
;
curl
${
BITBUCKET_OPTIONS
}
--netrc-file
/dev/stdin
${
BITBUCKET_ROOT_URL
}
/repositories/
${
BITBUCKET_REPO
}
/downloads
${
FILE_ARGS
}
)