Navigation Menu

Skip to content

Commit

Permalink
worker changes for build-level cloneURL
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
  • Loading branch information
krancour committed Aug 12, 2019
1 parent 6fbbed9 commit c8432df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions brigade-worker/src/index.ts
Expand Up @@ -8,6 +8,9 @@
* - `BRIGADE_EVENT_PROVIDER`: The name of the event provider, such as `github` or `dockerhub`
* - `BRIGADE_PROJECT_ID`: The project ID. This is used to load the Project
* object from configuration.
* - `BRIGADE_REMOTE_URL`: The URL from which to obtain source code to be built.
* This is optional. If left unset by the controller, the worker will fall
* back to a project-level URL.
* - `BRIGADE_COMMIT_ID`: The VCS commit ID (e.g. the Git commit)
* - `BRIGADE_COMMIT_REF`: The VCS full reference, defaults to
* `refs/heads/master`
Expand Down Expand Up @@ -107,6 +110,7 @@ let e: events.BrigadeEvent = {
workerID: process.env.BRIGADE_BUILD_NAME || `unknown-${defaultULID}`,
type: process.env.BRIGADE_EVENT_TYPE || "ping",
provider: process.env.BRIGADE_EVENT_PROVIDER || "unknown",
cloneURL: process.env.BRIGADE_REMOTE_URL,
revision: {
commit: process.env.BRIGADE_COMMIT_ID,
ref: process.env.BRIGADE_COMMIT_REF
Expand Down
11 changes: 10 additions & 1 deletion brigade-worker/src/k8s.ts
Expand Up @@ -839,6 +839,15 @@ function sidecarSpec(
imageTag = "brigadecore/git-sidecar:latest";
}

// Try to get cloneURL from the event first. This allows gateways to override
// the project-level cloneURL if the commit that should be built, for
// instance, exists only within a fork. If this isn't set at the event-level,
// fall back to the project-level default.
let cloneURL = e.cloneURL;
if (cloneURL == "") {
cloneURL = project.repo.cloneURL
}

let spec = new kubernetes.V1Container();
(spec.name = "vcs-sidecar"),
(spec.env = [
Expand All @@ -849,7 +858,7 @@ function sidecarSpec(
envVar("BRIGADE_EVENT_PROVIDER", e.provider),
envVar("BRIGADE_EVENT_TYPE", e.type),
envVar("BRIGADE_PROJECT_ID", project.id),
envVar("BRIGADE_REMOTE_URL", project.repo.cloneURL),
envVar("BRIGADE_REMOTE_URL", cloneURL),
envVar("BRIGADE_WORKSPACE", local),
envVar("BRIGADE_PROJECT_NAMESPACE", project.kubernetes.namespace),
envVar("BRIGADE_SUBMODULES", initGitSubmodules.toString()),
Expand Down

0 comments on commit c8432df

Please sign in to comment.