This repo is inspired by pickledrick/concourse-bitbucket-pullrequest-resource
A Concourse resource to trigger on commits to a specific branch on a private Bitbucket repository as well as interact with the build status API of Atlassian BitBucket.
This repo is tied to the associated Docker image on quay.io, built from the master branch.
These items go in the source
fields of the resource type. Bold items are required:
repo
- repository name to trackkey
- OAuth key for Consumerbranch
- the branch to check and getsecret
- OAuth Secret for Consumerteam
- Team name repository belongs toconcourse_url
- concourse url for setting build link in bitbucket (example:http://ci.example.com
)
Checks for commits on the specified repository and branch. If no version available (first run), will return the HEAD commit. If there is a current version available, will then return the ones newer than the current one.
Retrieves a copy of the commit and sets its build state to INPROGRESS
.
Updates the status of a commit.
Parameters:
commit
- File containing commit SHA to be updated.state
- the state of the status. Must be one ofsuccess
,failed
orinprogress
. By usinginprogress
we can use this resource for updating the status of builds but if you use this resource for get, perform task and then put, then the inprogress updating will be done for you by thein
script.
The logs can be found by running fly -t <target-name> intercept -c <pipeline-name>/<resource-name>
and then looking for check_logfile.txt
, in_logfile.txt
and out_logfile.txt
in the ~/root/
directory.
This resource can be added as a custom resource type, then defined as a resource and then used as follows
resource_types:
- name: concourse-bitbucket-resource
type: docker-image
source:
repository: quay.io/pontusarfwedson/concourse-bitbucket-resource
resources:
- name: ((repo))-test-pr-branch
type: concourse-bitbucket-resource
source:
repo: ((repo))
branch: "TEST_PR"
secret: ((bitbucket_secret))
key: ((bitbucket_key))
team: teamname
concourse_url: https://concourse-url.com
jobs:
- name: test-((repo))-poar-bitbucket-resource
plan:
- get: ((repo))-test-pr-branch
trigger: true
- task: test-((repo))-TEST-PR-branch
privileged: true
file: ((repo))-test-pr-branch/build/tasks/task.yaml
input_mapping: {repo: ((repo))-test-pr-branch}
params:
REPO: ((repo))
BRANCH: TEST_PR
on_success:
put: ((repo))-test-pr-branch
params:
commit: ((repo))-test-pr-branch/commit
state: success
on_failure:
put: ((repo))-test-pr-branch
params:
commit: ((repo))-test-pr-branch/commit
state: failed