How to get global input and use it across all pipeline steps

Is there a way to get an input parameter and have the parameter available across all input steps?

For instance, in jenkins, I can define a top-level input parameter BRANCH, and use it across multiple steps:

parameters {
string(
name: ‘BRANCH’,
defaultValue: ‘master’,
description: ‘branch to build’
)
}

Alternatively, is there a way to share an input parameter across steps? For instance, the first step gets a parameter, and I would like following steps to be able read that parameter.

Hey @Derrick, welcome to the community!

You can use an input step to collect input, assign the value to a key, and access that key with the buildkite-agent meta-data command.

Hopefully that helps you get started, and if you have other questions feel free to reach out :slight_smile:

Best,

Jeremy

Thanks, understood. My question is whether the input obtained in one step can be used in a following step.

Eg. ‘my-input’ is obtained in Step A. Can ‘my-input’ be used in Step B?

Since my-input would be stored as meta-data, it would not be available in a conditional within the pipeline, but you would be able to access it in Step B. If you are wanting to use it in a conditional though, you would need to use the buildkite-agent meta-data command and some scripting. There is a great example of how to do this over in this thread:

Hope that helps!