dockercontinuous-integrationbitbucketrunner

How to run a script from another repo on a Windows self-hosted bitbucket runner


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.zip
cd .\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# ls
bin  docker  entrypoint.sh  README.md  target

and I see no repository in my filesystem...

Thanks a lot for any help or hint!


Solution

  • I managed to do as I wanted:

    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/build
    ls
    git clone ...
    <testing other commands>
    
              script:
                - git clone git@bitbucket.org:suricog/tools.git ../tools
                - sh ../tools/useful_scripts/build.sh -v
                - pytest -v