Git commands on pipelines

I m trying to run some git commands on the pipeline, I tried two solutions none of them worked;

1. 

- generated an ssh key from the repository settings

- copied the public key into the authorized_keys file via this command. (this command is in the .yml file )

- cat my_ssh_key.pub >> ~/.ssh/authorized_keys

2. 

- git config user.name $MY_GIT_USERNAME
- git config user.email $MY_GIT_EMAIL

 Note: the repository is a bitbucket repos and is where the pipeline is running. So no external repos.

Also followed the steps here but it's not helping 

https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.html

Am I missing something ?

1 answer

When you configure an SSH key in your repository's Settings > Pipelines > SSH keys, you are presented with two options:

  • Generate keys
    This automatically generates a public and private SSH key pair. The private key can be used with SSH to access the Git repository on a read-only basis. This isn't very useful if you want to push to Git from a pipeline.
  • Use my own keys
    This allows you to provide SSH keys that have been granted access to your Git repo. It is possible to generate SSH keys that grant write access to the Git repo. See below for details

Obviously you want the Use my own keys option which grants read and write access. You can use team-level SSH keys so that CI scripts aren't tied to a specific user (although you'll get warnings about it).

Here's the process:

  • generate an SSH key pair on your local machine,
  • add the public key to the SSH keys in your Bitbucket team (Your team > Settings > Security > SSH keys),
  • add the same public key and the corresponding private key to Pipelines via Settings > Pipelines > SSH keys.

Here's hoping Bitbucket Pipelines will provide much easier git write access and hopefully before Bitbucket removes team-level SSH.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 3 hours ago in Agile

SIL Simplified - A beginner's guide to Simple Issue Language and how to use it

As a Jira admin, looking for ways to expand your Jira functionality, you may have stumbled across people using and referring to this thing called SIL. Contrary to what some may think, SIL is not the ...

19 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you