Skip to content

Support batch build in AWS codebuild#1369

Merged
orta merged 4 commits into
danger:masterfrom
ihatov08:support_batch_build
Sep 2, 2022
Merged

Support batch build in AWS codebuild#1369
orta merged 4 commits into
danger:masterfrom
ihatov08:support_batch_build

Conversation

@tomoya-yoshida-dwango

Copy link
Copy Markdown

CODEBUILD_SOURCE_VERSION environment variable returns commit hash(example: 6548dbc49fe57e1fe7507a7a4b815639a62e9f90) in a batch build when triggered by a pull request.

CODEBUILD_WEBHOOK_TRIGGER environment variable rerurns {event_name}/{event_variable}(example pr/123) in both normal build and batch build.

CODEBUILD_WEBHOOK_TRIGGER
Shows the webhook event that triggered the build. This variable is available only for builds triggered by a webhook. The value is parsed from the payload sent to CodeBuild by GitHub, GitHub Enterprise Server, or Bitbucket. The value's format depends on what type of event triggered the build.
For builds triggered by a pull request, it is pr/pull-request-number.
For builds triggered by creating a new branch or pushing a commit to a branch, it is branch/branch-name.
For builds triggered by a pushing a tag to a repository, it is tag/tag-name.

https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

Therefore, use CODEBUILD_WEBHOOK_TRIGGER environment variable so that danger works only when event_type is pr.

@orta

orta commented Jun 28, 2022

Copy link
Copy Markdown
Member

Ah, I don't know enough about codebuild to know if this is a breaking change - can people self host?

@tomoya-yoshida-dwango

Copy link
Copy Markdown
Author

Ah, I don't know enough about codebuild to know if this is a breaking change - can people self host?

Yes, we can.
We are using codebuild.
It is working.

@orta

orta commented Jun 28, 2022

Copy link
Copy Markdown
Member

If you can self-host then there may be cases where this new code breaks old builds - any chance you can make it backwards compatible? e.g. prioritise the new ENV vars but still keep the old ones working

@tomoya-yoshida-dwango

tomoya-yoshida-dwango commented Jun 29, 2022

Copy link
Copy Markdown
Author

@orta
For safety, if you want to keep the old ones working, I can implement it.

CODEBUILD_BATCH_BUILD_IDENTIFIER environment variable seems to be able to determine the mode of the code build, so use this to maintain backward compatibility.

@tomoya-yoshida-dwango

tomoya-yoshida-dwango commented Jun 29, 2022

Copy link
Copy Markdown
Author

@orta
Or is it better to have backward compatibility with a new environment variable that is not a CODEBUILD_BATCH_BUILD_IDENTIFIER environment variable?

If so, what is the better name for the new environment variable?

@orta

orta commented Jun 29, 2022

Copy link
Copy Markdown
Member

Yep, keep CODEBUILD_WEBHOOK_TRIGGER working if CODEBUILD_WEBHOOK_TRIGGER is not present

@tomoya-yoshida-dwango

Copy link
Copy Markdown
Author

@orta
CODEBUILD_WEBHOOK_TRIGGER environment variable always returns a value at coudebuild when created PR.(ex pr/121)

CODEBUILD_BATCH_BUILD_IDENTIFIER returns a value only with batch build(ex build1)

I implement it has backward compatibility depending on the present CODEBUILD_BATCH_BUILD_IDENTIFIER.
Please review πŸ™‡

@ihatov08 ihatov08 force-pushed the support_batch_build branch from ac1330b to cbfe3c2 Compare June 29, 2022 08:42
@ihatov08 ihatov08 force-pushed the support_batch_build branch from cbfe3c2 to 95a05ae Compare June 29, 2022 08:48
@orta

orta commented Sep 2, 2022

Copy link
Copy Markdown
Member

Looks great, sorry of the delay!

@orta orta merged commit c9c4b11 into danger:master Sep 2, 2022
@MotohikoNagano MotohikoNagano deleted the support_batch_build branch September 25, 2024 10:32
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.

3 participants