Adds CodeBuild support for builds that are not initiated via a webhook #2468
+34
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current CodeBuild support only supports retrieving the branch when a build has been initiated via a webhook, mainly GitHub. There are other use cases when a this environment variable will not be populated, and branch name is available via the
CODEBUILD_SOURCE_VERSION
variable. This PR updates the CodeBuild agent to also check this environment variable.This does result in a difference from the other build agents, as this involves 2 possible environment variables.
Description
Updates the CodeBuild agent to check the
CODEBUILD_SOURCE_VERSION
if the value fromCODEBUILD_WEBHOOK_BASE_REF
is null or empty. Overloads the base class so it no longer uses theEnvironmentVariable
property, as there are 2 variables to be checked. Throws an exception if the property is accessedMotivation and Context
We want to use GItVersion within CodeBuild from builds initiated from Jenkins that are initiated via webhook
How Has This Been Tested?
Added additional unit tests and confirmed they pass
Checklist: