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

using variables in Windows runner

Hello,

I would like to use the variables in the pipeline. All the instructions I have found have unfortunately not worked. By luck I found a file in which the variables are named differently. I tested this and finally got a result.
According to the instructions the variables should be named like this: $MY_Test. But this does not work. If I name the variable $Env:MY_Test, I get the content back.
I also noticed that the content of some variables is wrong. I think the data does not fit to Windows system yet.
The variable BITBUCKET_CLONE_DIR contains a Linux path.

10 comments

Comment

Log in or Sign up to comment
Jayant Gawali
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 29, 2021

Hi @Gabrisch ,

Thanks for raising this issue we will look into it and get back to you soon.

 

-Jayant

lliang2
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 5, 2022

Hey @Gabrisch

Yes, the syntax powershell use env var is different from how to use in bash or sh. So most of the doc you found need to be updated to `$Env:MY_Test` if you are using windows runner.

Do you mind to show us the links for the instructions you found? We will make sure to update them accordingly before open beta.

Cheers

Leo Liang

Gabrisch January 5, 2022

Hello,

I think that this description contains the biggest part:

https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/

But even here, the variables are used:

https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/

What about the wrong content of the variables, like for example: BITBUCKET_CLONE_DIR

lliang2
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 6, 2022

Hey @Gabrisch 

We are currently working on a fix for `BITBUCKET_CLONE_DIR` at the moment, I will let you know once it is merged.

Cheers

Leo Liang

lliang2
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 16, 2022

Hey @Gabrisch ,

We fixed the `BITBUCKET_CLONE_DIR` variable issue in latest runner. You can download the latest version with this command:

```

Invoke-WebRequest -Uri https://product-downloads.atlassian.com/software/bitbucket/pipelines/atlassian-bitbucket-pipelines-run
ner-1.277.zip -OutFile .\atlassian-bitbucket-pipelines-runner.zip

```

And you should be able to see the correct clone dir.

Cheers

Leo Liang

Gabrisch January 19, 2022

In the version the artifacts work in the meantime. Is it possible to specify the paths and files by variables? Unfortunately, this did not work in my tests.

- step:
name: Build Projekt
runs-on:
- 'self.hosted'
- 'windows'
clone:
enabled: false
script:


[...]

artifacts:
 - $Env:BITBUCKET_REPO_SLUG\Programm\Win32\Release\**

lliang2
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 20, 2022

Hey @Gabrisch 

Sorry that we don't support that, but you can add a comment in this open issue:
https://jira.atlassian.com/browse/BCLOUD-21101

And we will work on it base on the priority.

Cheers

Leo Liang

Poat March 17, 2022

Hey @lliang2 ,

 

Is it possible you mention this on this doc - https://support.atlassian.com/bitbucket-cloud/docs/set-up-runners-for-windows/

 

Just got done setting this up and didn't realize the nuance when my variables were all blank.

The document has examples like $MY_SSH_KEY and $USER that wouldn't work in Windows Powershell w/o the $Env:

Like # people like this
Oskar April 19, 2023

Hey!

I agree with @Poat . Please add this as an important mention in the documentation. It is not inherently clear anywhere in the docs.

I wasted a few good hours trying to figure out where I was going wrong before finding this post.

Hernando Gallego July 19, 2023

Team, please update the variables sites for this. 

+ echo $env:BITBUCKET_COMMIT
fcd0a69c2790d16099d00e61561aa3419024d752

Adding the $env:<variable_name> works on Windows, but is not specified on the online documentation for bitbucket pipeline. 

 

Thanks.

Like Maxim Rubis likes this
TAGS
AUG Leaders

Atlassian Community Events