buildkite / feedback

Got feedback? Please let us know!
https://buildkite.com
25 stars 24 forks source link

Overriding environment variable in a pipeline doesn't work when steps are uploaded from agent #323

Closed lankaapura closed 5 years ago

lankaapura commented 6 years ago

I have a windows buildkite agent configured to upload steps as per documentation. However, it seems that overriding environment variables don't work with it. But it works fine if I defined same steps on the portal without uploading thru the agent.

env:
  module_name: "Web"
  project_path: "..\\Source\\Web.csproj"

steps:

  - command: "powershell.exe build\\build.ps1"
    label: ":hammer: Build"

  - wait

  - command: "powershell.exe build\\publish-website.ps1"
    label: "Deploy Web"
    env:
      module_name: "Web"
      project_path: "..\\Source\\Web.csproj"
    branches: "master"

  - wait

  - command: "powershell.exe build\\publish-website.ps1"
    label: "Deploy Identity Server"
    env:
      module_name: "IdentityServer"
      project_path: "..\\Source\\IdentityServer.csproj"
    branches: "master"

  - wait

  - block: "Release"
    prompt: "Fill out the details for release."
    fields: 
      - text: "Release Name"
        key: "release-name"
        required: false
      - text: "Changelog"
        key: "release-notes"
        required: false
      - select: "Type"
        key: "release-type"
        default: "patch"
        options:
        - label: "Major"
          value: "major"
        - label: "Minor"
          value: "minor"
        - label: "Patch"
          value: "patch"
      - text: "Rlease Version"
        key: "release-version"
        hint: "Keep empty to use auto-generated build number."
        required: false

  - command: "powershell.exe .buildkite\\release.ps1"
    label: "Publish :rocket:"
lox commented 6 years ago

Sorry you're having problems! So based on the above, it sounds like you aren't seeing % module_name% and %project_path% set correctly in your build steps?

lankaapura commented 6 years ago

yes, that's correct. I want to override module_name and project_path

lox commented 6 years ago

Sorry, I'm still not quite understanding! How are you wanting to override those values? I can just see them defined in the top-level env, which means they should be available to access in your build steps!

lankaapura commented 6 years ago

image

lankaapura commented 6 years ago

@lox seems this is already reported in https://github.com/buildkite/agent/issues/471 and fixed in https://github.com/buildkite/agent/releases/tag/v3.0-beta.34

Do you have an ETA for v3 final release?

lox commented 6 years ago

Ah-hah! Sorry I missed the env entries in the individual blocks. I will double check that this is indeed fixed in the v3 agent.

We are hoping to have a final release for the v3 agent either this month or next!

lankaapura commented 6 years ago

cool. Thanks 👍

lankaapura commented 6 years ago

Any plans to fix this issue for 2.6? We don't have plans to update our agent to 3.0 yet since its still in beta.

keithpitt commented 5 years ago

@lankaapura 👋 sorry for the super long delay on following up on this! Just wanted to give you a heads up that our new YAML defined steps in the Buildkite UI gear fixes the precedence: https://forum.buildkite.community/t/defining-pipeline-build-steps-with-yaml/79

If you switch your pipelines to this format, it will fix that precedence logic to support your use case.

Let me know if you've got any follow up!

pmunin commented 2 years ago

I use .buildkite/pipeline.yml in my repo and see the same issue on agent v3.22.1