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

Help? How to run build using SSH (Not Https) for CI/CD (Windows Runner)

Valeriu Ghisoiu August 22, 2024

Hi,

sshbuildneed.png

I would like to ash how can the build run from the beginning, to the end using the SSH key on the machine where the Windows Runner is running.

 

The main repo somehow it is cloned through the pipeline, but when the submodules are updated the pipeline is failing. 

 

P.S I don't want to set in ".gitmodules" the URL: ssh://git@bitbucket.org/subrepo_name....

(This is working, but I want a relative URL in the ".gitmodules" like: url = "../subrepo_name".

 

The error in submodules update is:

"Please make sure you have the correct access rights and the repository exists.

fatal: clone of 'https://bitbucket.org/subrepo_name" into submodule path: <local runner path> failed 

Failed to clone <subrepo_name> Retry scheduled

ssh: Could not resolve hostname bitbucket.org:myRepo: Name or service not known

fatal: Could not read from remote repository."

 

Thanks so much in advance
Kind regards,
Vale

 

 

1 answer

1 accepted

1 vote
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 27, 2024

Hello @Valeriu Ghisoiu ,

and thank you for reaching out to the Community.

At the start of a build step, pipelines will by default clone the repository from which the build was triggered. This clone will use HTTPs and is authenticated through OAuth credentials generated automatically by pipeline itself. Unfortunately, it's not yet possible to change the protocol of this clone to SSH instead of HTTPS.

However, as a workaround, you can disable the pipeline's automatic clone of the repository, and make this clone manually as part of your step's script, so you have more control over the protocol and authentication mechanism.

clone:
enabled: false

pipelines:
default:
- step:
script:
- echo "No code cloned!"
- git clone git@bitbucket.org:WORKSPACE/REPO.git
- <rest of your commands>

Since you're using Windows runners, that is executed directly in Powershell, the runner will use the SSH keys configured in the host machine. If you haven't already, Setup the SSH keys in Windows , and once you confirm it's working through Powershell, it should work on Pipelines as well.

I hope that information helps!

Thank you, @Valeriu Ghisoiu !

Patrik S

Valeriu Ghisoiu August 28, 2024

Dear @Patrik S 

 

Thank you very much for your answer. This is without a doubt a really valuable answer.

The "clone: enabled: false" command that is huge! 

 

On the other hand I found also another workaround, because my problem was related to the work inside the clone, not really the first clone itself (which worked), but the things were happening after, which they were using also https.

 

So to just not change the files in the repo (for the sake of others) I chose to change to ssh only for that pipeline session/build like this:

```

script:
    - echo "Updating requirements.txt to use SSH instead of HTTPS."
    - (Get-Content requirements.txt) -replace 'https://bitbucket.org/', 'ssh://git@bitbucket.org/' | Set-Content requirements.txt
     
    - git remote set-url origin ssh://git@bitbucket.org/<domain>/<repo.git>
    - git remote -v

``` 

 

I have 2 more questions, they might be related to another topic but I make advantage of your answer. Please let me know if I open another topic for these:


1. With respect to "clone" command that you mentioned, I realise that are many commands for ci/cd which I don't really know them. THERE is any Documentation related to the commands and description of those? Can you share a link?

 

2. There is any documentation/link where I can find all the upgrades for the RUNNERS? I just saw Windows Runner 3.1.0 has been released. It was a jump from 2.6.0. So as a "rule" this means a big patch released, or important changes or adds. Can you please share a link to release notes for windows runners also?

 

Best,

Valeriu

 

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2024

Hey @Valeriu Ghisoiu ,

You're very welcome! Thanks for sharing your own workaround as well :)

As for your last two questions, let me address them individually for better clarity:

1.With respect to "clone" command that you mentioned, I realise that are many commands for ci/cd which I don't really know them.THERE is any Documentation related to the commands and description of those? Can you share a link?

Definitely! You can use the Bitbucket Pipelines configuration reference for a full list of commands available in Pipelines and their syntax in the YAML file.

 

2.There is any documentation/link where I can find all the upgrades for the RUNNERS? I just saw Windows Runner 3.1.0 has been released. It was a jump from 2.6.0. So as a "rule" this means a big patch released, or important changes or adds.Can you please share a link to release notes for windows runners also?

Since runner v2.0, our engineering team has started to publish the changelogs of major and minor changes on Bitbucket Runners Changelog. You can use that page to understand what changes were introduced in the recent releases of the runner.

Thank you, @Valeriu Ghisoiu !

Patrik S

Valeriu Ghisoiu August 29, 2024

Hi @Patrik S ,

 

Thank you for your answers.

With your help I just did find the "Step Options Web Page", that was what I needed. Of course I don't see all the option cases, as an example the one that you suggested is missing. And it might be even more that are not deep explained: 
clone :

 enabled: false (it is not existing)
As a feedback, maybe Atlassian team could improve these pages in the future. 


Also Thanks for the Runners Changelog. That I will save it for later, valuable page.

Best regards,

Valeriu

Suggest an answer

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

Atlassian Community Events