Skip to content

Commit f799484

Browse files
Merge pull request #14 from emerald-squad/personnal-acces-token
Add the possibility to authenticate using Personnal Access Tokens
2 parents db7cfb7 + 2d66844 commit f799484

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ See [concourse docs](http://concourse.ci/configuring-resource-types.html) for mo
4545

4646
* `password`: *Optional.* Password for HTTP(S) auth when pulling/pushing.
4747

48+
* `token`: *Optional.* Token for HTTP(S) auth when pulling/pushing.
49+
If you have configured a [personal access token](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html), you can use it instead of your username and password.
50+
4851
* `skip_ssl_verification`: *Optional.* Skips git ssl verification by exporting `GIT_SSL_NO_VERIFY=true`.
4952

5053
* `git_config`: *Optional*. If specified as (list of pairs `name` and `value`) it will configure git global options, setting each name with each value.

assets/helpers/bitbucket.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bitbucket_request() {
5353
extra_options+=" -k"
5454
fi
5555

56-
curl_cmd="curl -s --netrc-file \"$netrc_file\" $extra_options \"$request_url\" > \"$request_result\""
56+
curl_cmd="curl -s --netrc-file \"$netrc_file\" $TOKEN $extra_options \"$request_url\" > \"$request_result\""
5757
if ! eval $curl_cmd; then
5858
log "Bitbucket request $request_url failed"
5959
exit 1

assets/helpers/git.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,15 @@ pullrequest_metadata() {
107107
configure_credentials() {
108108
local username=$(jq -r '.source.username // ""' < $1)
109109
local password=$(jq -r '.source.password // ""' < $1)
110+
local token=$(jq -r '.source.token // ""' < $1)
110111

111112
rm -f $HOME/.netrc
112113
if [ "$username" != "" -a "$password" != "" ]; then
113114
echo "default login $username password $password" > $HOME/.netrc
114115
fi
116+
117+
if [ "$token" != "" ]; then
118+
git config --global --add http.extraHeader "Authorization: Bearer $token"
119+
TOKEN="-H \"Authorization: Bearer $token\""
120+
fi
115121
}

0 commit comments

Comments
 (0)