feat(besadii): Propagate Gerrit change ID & patchset to Buildkite
I previously implemented this in a CL that ended up being abandoned, but it turns out we need it for the hook setup, anyways. These environment variables become available during the build and, crucially, to the post-build hooks. Change-Id: Id6c1657947995e8bae1fa7b76184dd8be4c01525 Reviewed-on: https://cl.tvl.fyi/c/depot/+/739 Reviewed-by: Kane York <rikingcoding@gmail.com>
This commit is contained in:
parent
1397cbce52
commit
0bb24ed700
1 changed files with 9 additions and 4 deletions
|
@ -47,17 +47,21 @@ type Author struct {
|
||||||
// Build is the representation of a Buildkite build as described on
|
// Build is the representation of a Buildkite build as described on
|
||||||
// https://buildkite.com/docs/apis/rest-api/builds#create-a-build
|
// https://buildkite.com/docs/apis/rest-api/builds#create-a-build
|
||||||
type Build struct {
|
type Build struct {
|
||||||
Commit string `json:"commit"`
|
Commit string `json:"commit"`
|
||||||
Branch string `json:"branch"`
|
Branch string `json:"branch"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Author Author `json:"author"`
|
Author Author `json:"author"`
|
||||||
|
Env map[string]string `json:"env"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger a build of a given branch & commit on Buildkite
|
// Trigger a build of a given branch & commit on Buildkite
|
||||||
func triggerBuild(log *syslog.Writer, token string, update *refUpdated) error {
|
func triggerBuild(log *syslog.Writer, token string, update *refUpdated) error {
|
||||||
var message string
|
var message string
|
||||||
|
env := make(map[string]string)
|
||||||
|
|
||||||
if update.changeId != nil && update.patchset != nil {
|
if update.changeId != nil && update.patchset != nil {
|
||||||
|
env["GERRIT_CHANGE_ID"] = *update.changeId
|
||||||
|
env["GERRIT_PATCHSET"] = *update.patchset
|
||||||
message = fmt.Sprintf(":llama: depot @ https://cl.tvl.fyi/c/depot/+/%s/%s", *update.changeId, *update.patchset)
|
message = fmt.Sprintf(":llama: depot @ https://cl.tvl.fyi/c/depot/+/%s/%s", *update.changeId, *update.patchset)
|
||||||
} else {
|
} else {
|
||||||
message = fmt.Sprintf(":llama: depot @ %s", update.commit)
|
message = fmt.Sprintf(":llama: depot @ %s", update.commit)
|
||||||
|
@ -67,6 +71,7 @@ func triggerBuild(log *syslog.Writer, token string, update *refUpdated) error {
|
||||||
Commit: update.commit,
|
Commit: update.commit,
|
||||||
Branch: update.ref,
|
Branch: update.ref,
|
||||||
Message: message,
|
Message: message,
|
||||||
|
Env: env,
|
||||||
Author: Author{
|
Author: Author{
|
||||||
Name: update.submitter,
|
Name: update.submitter,
|
||||||
Email: update.email,
|
Email: update.email,
|
||||||
|
|
Loading…
Reference in a new issue