Skip to content

Add CodeBuild support #1841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2019
Merged

Add CodeBuild support #1841

merged 1 commit into from
Oct 14, 2019

Conversation

derwasp
Copy link
Contributor

@derwasp derwasp commented Oct 6, 2019

Add CodeBuild support based on the CODEBUILD_WEBHOOK_HEAD_REF environment variable documented here. It seems like currently, this is the only way to determine the branch name in CodeBuild.

Though the documentation states that CODEBUILD_SOURCE_VERSION for GitHub can also be

branch name, or tag name associated with the version of the source code to be built

this is what an export output shows for a build triggered by a GitHub webhook:

export CODEBUILD_AGENT_ENDPOINT='http://127.0.0.1:7831'
export CODEBUILD_AUTH_TOKEN='359a05a3-4ca9-4e45-8237-297e076628bf'
export CODEBUILD_BMR_URL='https://CODEBUILD_AGENT:3000'
export CODEBUILD_BUILD_ARN='arn:aws:codebuild:eu-west-1:527837446413:build/DZ-DELETEME:4d2cce79-1e48-4525-bfc4-22c1c0f3088b''
export CODEBUILD_BUILD_ID='DZ-DELETEME:4d2cce79-1e48-4525-bfc4-22c1c0f3088b'
export CODEBUILD_BUILD_IMAGE='aws/codebuild/standard:2.0'
export CODEBUILD_BUILD_SUCCEEDING='1'
export CODEBUILD_BUILD_URL=[REDACTED]
export CODEBUILD_CI='true'
export CODEBUILD_CONTAINER_NAME='default'
export CODEBUILD_EXECUTION_ROLE_BUILD=''
export CODEBUILD_GOPATH='/codebuild/output/src322582804'
export CODEBUILD_INITIATOR='GitHub-Hookshot/951dca1'
export CODEBUILD_KMS_KEY_ID=[REDACTED]
export CODEBUILD_LAST_EXIT='0'
export CODEBUILD_LOG_PATH='9a1704b1-6113-4858-8e28-d19b156c9da3'
export CODEBUILD_PROJECT_UUID='a419f548-3f2a-419b-aff9-becca6830831'
export CODEBUILD_RESOLVED_SOURCE_VERSION='9f74be745a0ea7b2a088581305ac0a2e8c62e173'
export CODEBUILD_SOURCE_REPO_URL='https://github.com/derwasp/somerepo'
export CODEBUILD_SOURCE_VERSION='9f74be745a0ea7b2a088581305ac0a2e8c62e173'
export CODEBUILD_SRC_DIR='/codebuild/output/src322582804/src/github.com/derwasp/somerepo'
export CODEBUILD_START_TIME='1569507961804'
export CODEBUILD_WEBHOOK_ACTOR_ACCOUNT_ID='99999999'
export CODEBUILD_WEBHOOK_EVENT='PUSH'
export CODEBUILD_WEBHOOK_HEAD_REF='refs/heads/feature/testfeature'
export CODEBUILD_WEBHOOK_PREV_COMMIT='0000000000000000000000000000000000000000'
export CODEBUILD_WEBHOOK_TRIGGER='branch/feature/testfeature'

Here the branch name is feature/testfeature and as it can be seen it's only mentioned in CODEBUILD_WEBHOOK_HEAD_REF and CODEBUILD_WEBHOOK_TRIGGER.

CODEBUILD_WEBHOOK_HEAD_REF seems to be a direct map from Github's push event's ref field.

Closes #1771

@derwasp derwasp marked this pull request as ready for review October 6, 2019 11:21
@derwasp
Copy link
Contributor Author

derwasp commented Oct 14, 2019

@asbjornu @arturcic I would appreciate any feedback on the PR ;)

@asbjornu
Copy link
Member

I have no idea what CodeBuild even is, so I can't review this in any meaningful way, but as the tests are green and I assume you've tested this, I'll merge as soon as the PR is up to date with HEAD of master. 😃

@derwasp
Copy link
Contributor Author

derwasp commented Oct 14, 2019

@asbjornu I hope I tested it enough :)
CodeBuild is a very simple build server/service from AWS, similar to Azure Pipelines and others. But I guess you figured that out :)

Add CodeBuild support based on the CODEBUILD_WEBHOOK_HEAD_REF environment variables as documented here:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
Currently this is the only way to determine the branch name in CodeBuild.
@asbjornu asbjornu merged commit 0fc8f59 into GitTools:master Oct 14, 2019
@asbjornu
Copy link
Member

Thank you for your contributions, @derwasp. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CodeBuild CI
2 participants