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

How do I stop my Pipeline from running after each commit with a selfhosted Runner?

Jonas Augustin May 16, 2023

Hello,

Is there a way to configure my Pipeline with a selfhosted-Runner to only manually run my Pipeline?

According to https://support.atlassian.com/bitbucket-cloud/docs/pipeline-triggers/ I have to define a custom Pipeline for this. But then my Pipeline displays this:

CustomnotonSelfhosted.PNG

My Test yaml code looks like this atm:

pipelines:
custom:
build-and-test:
- step:
runs-on:
- self.hosted
- windows
name: Build and Test
image: mcr.microsoft.com/dotnet/sdk:6.0
caches:
- dotnetcore
script:
- echo 'Checking if mssql container exists...'
- if (docker ps -a --format '{{.Names}}' -match '^mssql$') { echo 'Removing existing mssql container...'; docker rm -f mssql }
- echo 'Starting SQL Server Docker container...'
- docker run --name mssql -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=SecurePW123!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
- echo 'Wait for SQL Server to start...'
- sleep 30
- echo 'Running database setup script...'
- sqlcmd -S localhost -U sa -P "SecurePW123!" -Q "CREATE DATABASE TestDB;"
- |
sqlcmd -S localhost -U sa -P "SecurePW123!" -d TestDB -Q "
CREATE TABLE Customers (CustomerId INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50));
INSERT INTO Customers (CustomerId, FirstName, LastName) VALUES (1, 'John', 'Doe'), (2, 'Jane', 'Doe');"
- dotnet restore netCo.Butler.UnittestDemo/UnittestDemo.sln
- dotnet build --no-restore netCo.Butler.UnittestDemo/UnittestDemo.sln
- dotnet test --no-build --verbosity normal netCo.Butler.UnittestDemo.Tests/netCo.Butler.UnittestDemo.Tests.csproj

If I change it back to "default" it works fine.

Is there any other way to only run the Pipeline manually(via API call) while using a selfhosted Runner?

 

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 17, 2023

Hi Jonas,

The error is not referring to the use of a custom pipeline, but to the use of the image in the step:

image: mcr.microsoft.com/dotnet/sdk:6.0

Based on the runner label, I assume you are using a Windows Runner? Windows Runners do not use Docker and the builds do not run in Docker containers. They use PowerShell to run pipeline steps on your Windows machine (host device). The image definition makes sense only for Pipelines builds that run in our own infrastructure or in a Linux Docker Runner.

You need to remove the image definition and this error should not occur then.

Running a custom pipeline via API is also possible, as long as you remove the image definition:

Kind regards,
Theodora

Jonas Augustin May 19, 2023

Thank you very much Theodora!

That fixed my Problem😃

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2023

You are very welcome Jonas, I'm glad to have helped!

Please feel free to reach out if you ever need anything else!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events