How to run a script from another repo on a Windows self-hosted bitbucket runner
Asked by PJ127:

I am new to pipelines and runners. I want to simply build my python code after a pull-request or when I want. But **my build script is in another repository**. I don't know how to get this file. On my local machine, I simply do, from my current repository:

    ../tools/build.sh

I created a Windows-64 Workspace runner in the bitbucket interface, and then copy-pasted the 3 lines to download and start it on my local machine:

    Expand-Archive .\atlassian-bitbucket-pipelines-runner.zipcd .\atlassian-bitbucket-pipelines-runner\bin.\start.ps1 -accountUuid '<ACCOUNT_ID>' -runnerUuid '<etc.>

Then my runner is working.

    [2024-05-30 10:03:15,341] Runner version: 2.1.0[2024-05-30 10:03:20,832] Runner runtime: windows-powershell[2024-05-30 10:03:20,973] Starting websocket listening to RUNNER_UPDATED events.[2024-05-30 10:03:21,236] Updating runner status to "ONLINE" and checking for new steps assigned to the runner after 0 seconds and then every 30 seconds.[2024-05-30 10:03:21,553] Updating runner state to "ONLINE".[2024-05-30 10:03:51,246] Updating runner state to "ONLINE"....

But I can't get into a bash prompt. Where are my source files located? I imagine in `'.'`. But do I have other repos accessible in a `Workspace` runner, or should I `git clone` them to have access to the files?

*Bonus question* : how do I debug this, without having to change my `bitbucket-pipelines.yml` file online and send my request through bitbucket online UI, for a very painful debugging? I would like to enter my runner locally on a bash, like in a Docker container, and see the filesystem, start my build, etc.

Note that on an Ubuntu self-hosted runner, I manage to enter the docker container (Windows runners are not docker containers if I understood well), but I can't find any source code:

    root@623d8692a688:/opt/atlassian/pipelines/runner# lsbin  docker  entrypoint.sh  README.md  target

and I see no repository in my filesystem...

Thanks a lot for any help or hint!


Answers:
author: Mark C
body: Hi [@PJ127](/t5/user/viewprofilepage/user-id/4935453)

Welcome to the community.

In order to run scripts from another repository in Pipelines Windows Runners, you can clone the specific repository and run the scripts.  
To debug Windows runners, you'll need to access the runners directory from where you installed the runner and access the file called "runner.log".

You can also refer to this existing documentation on [Troubleshooting runners](https://confluence.atlassian.com/bbkb/troubleshooting-runners-1167819666.html).

Regards,  
Mark C

comments: author: PJ127
body: Thank you for your answer. That very morning I managed to find the solution (thanks for confirming the git clone step).

As for the debugging or runners, I didn't make myself clear: I want to enter the shell and test commands, not debug afterwards. I found a way.

I added a \`sleep\` step at the beginning of \`script\`:

    pipelines:  default:      - step:          runs-on:            - self.hosted            - windows          script:            - sleep 6000

Then I click on `Run pipeline` from the bitbucket interface. Finally, in a second Powershell (the first one is executing the runner, see my question), I can peacefully navigate in the filesystem, not yet deleted:

    d:cd  dev/atlassian-bitbucket-pipelines-runner/temp/cf337094-48aa-5bd5-98a4-bf0712e387bf/1717479636626/buildlsgit clone ...<testing other commands>

See my [StackOverflow answer](https://stackoverflow.com/questions/78555513/how-to-run-a-script-from-another-repo-on-a-windows-self-hosted-bitbucket-runner/78578951#78578951) for more details.


Tags: bitbucket-cloud

bitbucket-runners

cloud