Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Deploy variable value in PowerShell

Dmitriy Kagarlickij May 13, 2024

I need value that user entered on the pipeline start to be used in the pipeline,

Pipeline is running on self-hosted windows agent and I need value to be used in PowerShell 

My pipeline looks like this - 

```

pipelines:
  custom:
    deploy:
      - variables:
        - name: myVar
      - step:
          runs-on:
            - windows
            - self.hosted
          script:
            - Write-Output "myVar = $env:myVar"

```

I enter `myValue` on pipeline run, but Write-Output displays `myVar = true` instead of `myVar = myValue`

If I use built-in variables, e.g. `Write-Output "myVar = $env:BITBUCKET_BUILD_NUMBER"` output is with correct value (`myVar = 22`)

So how can I get the value that user entered on pipeline start? 

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 14, 2024

Hello @Dmitriy Kagarlickij ,

thank you for reaching out to Community!

The custom variables provided on the pipeline start should also work on Windows Runners with no required additional configuration.

I was able to confirm that in my test environment with Windows runners, where the variable provided was correctly printed in the logs with the value put at the pipeline start.

In this case, to confirm if the variable is being passed to the build, could you expand the Build Setup section on the logs, and look for the session named Pipeline variables ? That section will contain all the custom variables provided to the pipeline : 

Screenshot 2024-05-14 at 3.50.19 PM.png

In the example above, I had a variable named myVar and provided the value "testingValue" when triggering the pipeline.

Could you verify if your pipeline has a similar log?

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events