Have a couple questions about pipelines on runners
Asked by Keith Smith:

Here are my questions about my pipeline runner:

1) Exactly where are my commands going to, and are they segregated by process ID or do they run as a block? For instance if my pipeline involves pulling an account and saving to a variable, will that be available for the next command?

2) If I am running my pipeline in windows, am I to use CMD commands or PS commands?

I ask this because just as a quick test, I set up my pipeline like this:

branches:  
feature/\*:  
- step:  
runs-on:  
- self.hosted  
- windows  
name: 'Build'  
script:  
- echo "Build step on feature branches"  
- Get-Location \| Write-Output  
- Get-ChildItem \| Write-Output

The echo command provides output in the trace but the next two commands do nothing. What I really want to do is to cd to a folder and do an ant build, but if I can't get even a pwd to produce output, I can't proceed.


Answers:
author: Theodora Boudale
body: Hi Keith,

Windows Runners use PowerShell to run pipeline steps on your windows machine. If you define a variable during a step, it will be available to the rest of the commands in the same step (but not in a subsequent step).

You can use PowerShell commands. Many CMD commands work in PowerShell as well, for example, you can use a cd command.

You mentioned that you don't see output from certain commands.

* Can you please confirm if you are executing the runner in a [supported platform](https://support.atlassian.com/bitbucket-cloud/docs/runners/#Supported-platforms) that meets the [minimum requirements](https://support.atlassian.com/bitbucket-cloud/docs/runners/#Minimum-Requirements) for Windows? Could you also let us what version you are using for the first four items listed in the requirements?  

* What version of the runner are you using and does it show to be the latest one? You can find that in the Pipelines build log in the section Runner.

Kind regards,  
Theodora

comments: author: Keith Smith
body: I am running Windows 10 Pro so that appears to be a supported platform.

Here is the output of Java -version:

openjdk version "11.0.15" 2022-04-19  
OpenJDK Runtime Environment Temurin-11.0.15+10 (build 11.0.15+10)  
OpenJDK 64-Bit Server VM Temurin-11.0.15+10 (build 11.0.15+10, mixed mode)

So I think I meet the minimum java version requirements

Here is my git version:

git version 2.38.1.windows.1

Here is my PS version:

PSVersion 5.1.19041.2364

I have 64GB of RAM

I have enabled unsigned scripts (the echo command would not have worked, right)

I have disabled pagefile and swapfile.

You can see my example script in my original post

Runner version 1.382

I can upper and lower bound my commands with an echo command but any command in between provides no output.


author: Theodora Boudale
body: Hi Keith,

Thank you for the info.

Could you please update the runner to the latest version (1.388 at the moment for Windows Runners) and let me know if the issue is reproducible? You can delete or rename the existing runner directory, then use the following commands to download and expand the latest runner zip:

```
Invoke-WebRequest -Uri https://product-downloads.atlassian.com/software/bitbucket/pipelines/atlassian-bitbucket-pipelines-runner-1.388.zip -OutFile .\atlassian-bitbucket-pipelines-runner.zip

Expand-Archive .\atlassian-bitbucket-pipelines-runner.zip

cd .\atlassian-bitbucket-pipelines-runner\bin
```

Then, use the preconfigured command you were given when you created the runner in order to start it.

If the issue is still reproducible, can you please check the output of all commands and also the **Build teardown** section in the Pipelines build log, and see if the output perhaps shows under a different command or under the **Build teardown** section? I came across a bug where logs are sometimes displayed under the wrong commands, and I would like to understand if this is what happens with your build or not.

Kind regards,  
Theodora


author: Keith Smith
body: Please hold... seems to be working. Runner is running in the runner folder. How do I cd to the top level folder of my archive? I tried a couple of these parameters but can't find one that works

I tried:

cd $env:BITBUCKET_WORKSPACE

that failed


author: Theodora Boudale
body: Hi Keith,

If you expand the runner archive in the directory **C:\\Users\\MyUser\\Documents\\atlassian-bitbucket-pipelines-runner**, then the repo will get cloned in the following directory on your machine when a build runs:

```
C:\Users\MyUser\Documents\atlassian-bitbucket-pipelines-runner\temp\{runner-uuid}\{some-number}\build
```

where  
**{runner-uuid}** is the UUID of the runner you are using  
**{some-number}** is a number based on the EPOCH time, when the build gets started

Please keep in mind that the runner always tries to clean up the **build** directory when the build is finished.

I'm not sure which directory you mean by "top level folder of my archive", do you want to cd to **C:\\Users\\MyUser\\Documents\\atlassian-bitbucket-pipelines-runner,**the directory where you expanded the runner zip?

If so, you can use the command **cd ../../../../** to go up 4 directory levels.

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-pipelines

cloud