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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,699
Community Members
 
Community Events
184
Community Groups

how to use git command in script task of bamboo

How can we use the command git in a script task, we already set git executable in server capabilities and clone a repository from bitbucket. Thanks in advance!

3 answers

The simplest way of doing this is to use the bamboo source code task to perform a check out of any old branch (master, develop, it doesn't matter).

The above will use the credentials you have setup inside bamboo to authenticate with bitbucket and clone the repository.

Once the bitbucket task has cloned your repository, all you then need to do is use a script task to do what you really want to do using git commands to dynamically switch branches, or whatever.
git checkout release/${bamboo.some.variable}

The point is, the bitbucket task does the clone of the whole repo, and manages the authentication. If you try it without using the bitbucket source code task, then you are just making it hard for yourself.

1 vote
Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Aug 31, 2016

First of all: what is the usecase for running checkout from command line and not with the source checkout task? 

Second: if you want to use git from script task you'll not be able to use any credentials defined in Bamboo - you need to provide all the authentication on your own.

0 votes
Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 24, 2016

As long as the path to the git command is set on system level you can execute git commands.

Hi we already set the path of our git.exe in bamboo server capabilities, but still we are encountering "CategoryInfo : ObjectNotFound: (git:String) [], CommandNotFound". Thanks for the quick response.git.PNG

Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 24, 2016

Not sure what the problem is, I've got exactly the same configuration.

Maybe the agent is running as a different user as the logged on user and does not have access rights to the defined directory?

 

Hi we can now use git command in a script task, but we are still enountering some problems. We do want to checkout a repository from Bitbucket using a passwordless(ssh). We already executed the ssh key generate command and place it on the access key of our project in bitbucket. But when we are running our build plan which is just cloning the repository via ssh we are getting host key verification failed. We also set our ssh key in bamboo shared credentials but still we are getting the same error. Hope anyone can help us. Thanks!

Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 25, 2016

Which Bitbucket are you using? 5.12.x? Have you marked "Manage Trusted Keys" in security settings

Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 25, 2016

does it work from the commmand line?

We're using Bitbucket 4.8.3 and bamboo 5.12.3.1. Yes it works when i tried it in the command line. Just a little bit confused, For Manage Trusted Keys it is only on the security settings of Bamboo therefore if someone connects with my bamboo then it will allow the connection, right? but what we want is to clone a repository from bitbuket using script task of bamboo. We are just using a local agent since both application only resides on my local machine.

Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 26, 2016

The trusted keys option is for apps communicating with Bamboo (like Bitbucket). You would also see errors in the bamboo.log

Mark we are still not able to clone a repository using script task. Please see attached configuration for your reference. Thanks.config.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events