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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to enable and use git push command in the Linux Shell Runner?

Illya Kuzmych
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Sep 27, 2023

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?

1 answer

1 accepted

2 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 28, 2023 • edited

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 : 

  • USERNAME : Your bitbucket account username. You can check it under your bitbucket profile
  • APP_PASS : An app password used to authenticate to bitbucket. If you haven't already, you will need to create an app password with at least repository:write permission for being able to push.

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events