monorepo-diff-buildkite-plugin icon indicating copy to clipboard operation
monorepo-diff-buildkite-plugin copied to clipboard

PR-related environment variables not passed down.

Open nicwise opened this issue 2 years ago • 3 comments

This is likely a buildkite issue, but it'd be good to know if anyone else is seeing this.

I have the usual:

  • Webhook triggers pipeline
  • Pipeline has single step, which is using this plugin
  • Plugin starts 1 or more other pipelines

If I look at the environment of the first step, I can see that BUILDKITE_PULL_REQUEST and a few others are set. Yay. Expected. If I look at the "1 or more" others, it is not - its set to false for no PR.

Likely also

BUILDKITE_PULL_REQUEST_BASE_BRANCH
BUILDKITE_PULL_REQUEST_REPO

I'd EXPECT buildkite pipeline upload.... to look at it, and carry them across, but it appears it doesn't. Anyone else see this, or have a work around? I need that specific variable name for the tool (DangerJs) I'm using, and likely other stuff too.

nicwise avatar May 23 '22 04:05 nicwise

turns out you have to manually pass them all thru.

            - path:
              - "paths-here/"
              config:
                trigger: "thing-to-trigger"
                build:
                  env:
                    - BUILDKITE_PULL_REQUEST
                    - BUILDKITE_PULL_REQUEST_BASE_BRANCH
                    - BUILDKITE_PULL_REQUEST_REPO

nicwise avatar Jun 02 '22 22:06 nicwise

I'm having the same problem. In my case the env attributes for build are not being passed to the triggered buildkite pipeline. Any help will be really appreciated.

  - label: "Building Docker Images"
    plugins:
      - chronotc/monorepo-diff#v2.3.0:
          diff: "git diff --name-only HEAD~1"
          watch:
            - path:
                - project1/
              config:    
                trigger: docker-build
                label: Build and Publish docker
                build:
                  env:
                    ENV_VAR: "./dir"
                    ENV_BAR: "tag"

Thanks in advance for reading.

alexis-hop avatar Aug 16 '22 22:08 alexis-hop

I just realized that env variables MUST be pass this way - ENV=VALUE

                trigger: docker-build
                label: Build and Publish docker
                build:
                  env:
                     - ENV_VAR="./dir"                    <======= This solve my problem.
                     - ENV_BAR="tag"

alexis-hop avatar Aug 17 '22 15:08 alexis-hop