Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local run doesn't pass environment variables in from steps #40

Closed
jamiebrynes7 opened this issue Feb 19, 2019 · 6 comments
Closed

local run doesn't pass environment variables in from steps #40

jamiebrynes7 opened this issue Feb 19, 2019 · 6 comments

Comments

@jamiebrynes7
Copy link

Hi there, I've got a steps file which includes steps with elements in the env field:

  - label: "build :android:"
    command: bash -c ci/build.sh
    <<: *common
    artifact_paths:
      - logs/**/*
    env: 
      WORKER_TYPE: "AndroidClient"
      BUILD_TARGET: "local"
      SCRIPTING_TYPE: "mono"

However, when I run bk-cli local run steps.yaml this step fails with:

ci/build.sh: line 8: WORKER_TYPE: unbound variable

Is this the intended behaviour?


OS: macOS 10.13.6
CLI version: 0.4.0
buildkite-agent version: 3.8.4, build 2783

@brendanlucas
Copy link

I am seeing the same issue. Have tried defining the env vars within the step explicitly and globally at the top of pipeline.yml?

It looks like the call to run the script is passing in empty arrays after uploading the pipeline:
$ bk local run --debug
...
~~~ Running commands $ /bin/bash -e -c "buildkite-agent pipeline upload" 2019-02-20 16:32:14 INFO Searching for pipeline config... 2019-02-20 16:32:14 INFO Found config file ".buildkite/pipeline.yml"
...
2019/02/20 16:32:15 Processing step {Command: {Label:Build Test & Push to ECR Commands:[/etc/buildkite-agent/buildkite-scripts/multistage-docker-build.sh] Plugins:[] Env:[] ArtifactPaths:[]}}
...
/etc/buildkite-agent/buildkite-scripts/multistage-docker-build.sh: line 90: TARGET_ECS_SERVICE: unbound variable
# ↳ Command completed in 4.317970499s
🚨 Error: The command exited with status 1

Not sure if this is a problem with bk cli or bk agent?

@tduffield
Copy link

I was able to work around the issue by passing the environment variables into the bk run command.

bk local run -E WORKER_TYPE="AndroidClient"

That might not unblock everyone, but it might unblock some people.

@tduffield
Copy link

I think there is some type mismatch between the local server and the upstream agent when it comes to the environment variables.

@tduffield
Copy link

I'm still stuck on this. I've been able to confirm that any env or environment settings in a pipeline definition file, either in map (FOO: "true") or slice (- "FOO=true") form, are ignored by bk local run.

@lox
Copy link

lox commented Mar 11, 2019

I’ll have a look today!

@drnic
Copy link

drnic commented Feb 24, 2020

I'm not able to figure out a combination of bk run local -E key=value where the env var is passed into my script.

My step runs in docker, but I have propagate-environment: true set.

  - label: ":cloudfoundry:"
    command: "ci/scripts/cf-push.sh"
    artifact_paths: "."
    concurrency: 1
    concurrency_group: "cf-push"
    plugins:
      - docker#v3.5.0:
          image: "starkandwayne/update-all-cf-buildpacks:latest"
          propagate-environment: true
    timeout_in_minutes: 5
    env:
      CF_API: ""

When I run bk local run -E CF_API=https://api.run.pivotal.io my script fails because $CF_API was not provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants