Using BUILDKITE_BUILD_NUMBER in pipeline.yml command

Hi Team,

I am trying to run the bat command under pipeline.yml steps.
Under bat command I need to pass the current build number ‘BUILDKITE_BUILD_NUMBER’, which I tried doing as variable interpolation, but don’t know why its value not getting passed.

Below is the yml file code, and would appreciate if you could guide me to the right direction.

pipeline.yml:

env:

steps:

  • label: “:hammer: Build”
    command: echo $$BUILD_NUMBER
    env:
    BUILD_NUMBER: BUILDKITE_BUILD_NUMBER
    key: build

Hi @Divakar ,

Welcome to the Buildkite Support Community! :wave:

To pass assign the env vars, you would need to pass with the $ char so the value is retrieved accordingly. So as the BUILDKITE_BUILD_NUMBER should be assigned to this way:

steps:

- label: “:hammer: Build”
  command: echo $$BUILD_NUMBER
  env:
       BUILD_NUMBER: $BUILDKITE_BUILD_NUMBER
key: build

Cheers,
Lizette

Hi Lizette,

I tried with the one you suggested earlier but in the buildkite console log it prints only $BUILD_NUMBER

Please see below the pipeline.yml and buildkite output.

pipeline.yml

env:

steps:

  • label: “:hammer: Build”
    command: echo $$BUILD_NUMBER
    env:
    BUILD_NUMBER: $BUILDKITE_BUILD_NUMBER
    key: build

Buildkite Output

$BUILD_NUMBER

Hey Divakar,

Are you able to send us the build url to support@buildkite.com so we can have a look at why it is not working for you?

Cheers,
Lizette

Hi Lizette,

I have sent it to the support@buildkite.com.

Kindly advise if in case you didn’t receive.

Thanks.

Thanks Lizette,

The issue resolved. As the agent machine was Windows, the parameter I passed it using %BUILD_NUMBER%

1 Like