I have been using a runner using Docker, and was able to execute my pipeline successfully each time. I have recently switched to Linux Shell as I do not want to reinstall dependencies each time I need to run the pipeline (no company artifactory available to store Docker images) and it is easier to just use the bash shell to do all the same commands.
I was able to set up the Linux Shell fine and it did all of my commands in my scripts successfully and as expected, however it is not able to do a git push, causing the pipeline to fail. I get this error in my pipeline that kills it:
fatal: could not read Username for 'https://bitbucket.org': No such device or address
What can I fix in my pipeline configuration or in my runner to allow for this to work successfully?
Hey @Illya Kuzmych !
Thanks for reaching out to the Community :)
Based on the error message being returned :
fatal: could not read Username for 'https://bitbucket.org': No such device or address
Git does not have the credentials configured for the authentication to the repository, causing the push to fail.
When trying to push back to the repository from within the pipeline using self-hosted linux shell runners, you will need to first set the credentials that will be used by git to authenticate with Bitbucket Cloud. This can be done by executing the following command as part of your pipeline before the push:
git remote set-url origin https://$USERNAME:$APP_PASS@bitbucket.org/WORKSPACE/RESPOSITORY.git
In this example we are considering the creation of environment variables named USERNAME and APP_PASS, where :
Following is an example pipeline using the command above :
pipelines:
default:
- step:
name: Test
runs-on:
- 'self.hosted'
- 'linux.shell'
script:
- git remote set-url origin https://$USERNAME:$APP_PASS@bitbucket.org/WORKSPACE/REPOSITORY.git
- touch fileA.txt
- git add .
- git commit -m "[skip ci] testing push from linux shell"
- git push
The [skip ci] label can be used in the commit message so this commit does not trigger a new pipeline build, which could cause pipelines to get into a loop.
Hope that helps! Let me know in case you have any questions.
Thank you, @Illya Kuzmych !
Patrik S
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.