buildkite / buildkite/agent

Agent does not verify requested commit-ish is in requested branch

Open
#409 0 comments 1 reaction 0 assignees View on GitHub
enhancement git
Dominant language
Go
Stars
1.1k
Forks
378
Avg merge
2d 6h
Merged PRs (30d)
74

Description

Currently, if you manually trigger a build, specifying both a branch and a commit-ish, the Agent treats the specified commit-ish as though it were in the specified branch.

In cases where you require specific things to happen on specific branches (i.e. deploy from master), this can cause issues.

A workaround for now is to implement a check in your own build scripts;

```bash
if ! git branch -r --contains "${BUILDKITE_COMMIT}" | grep -q "origin/${BUILDKITE_BRANCH}" 2> /dev/null; then
echo "The commit SHA ${BUILDKITE_COMMIT} was not found in ${BUILDKITE_BRANCH}. Exitting..."
exit 1
fi
```

(thanks to Jacob from Envato for investigation of this issue)

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Trace the Go code handling manually triggered builds and the branch/commit inputs, then reproduce a case where the requested commit is outside the requested branch. Done means the Agent detects and rejects that mismatch rather than proceeding.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
ci-cd, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.