How can I get the comments from a GIT commit from my Bamboo job

This is the scenario I would like to use. Our developer enters a control number(example AB123) in the commit message when he does a commit/push to Stash GIT from SourcerTree. Bamboo then would run a plan that executes a job that compiles the code and places the resulting exe/dll into the artifacts. I would then have a job that will run a script that builds a path including a folder named after the control number AB123 mentioned above. I would then copy the resulting artifact(exe or dll) to that \\path\folder. My question is: how do I access the value from the commit message from my Bamboo task/job?  I've read the variable section of the Bamboo documentation and I've looked into other topics that I thought might work but I haven't been able to piece it together. I'm sure the GIT commit message can be read from Bamboo, right? Is there a better way to get a custom value from GIT over to Bamboo? I'm brand new to both of these products. Thanks!     

1 answer

1 accepted

Hi Bruce,

Unfortunately commit messages aren't exposed as variables, here is the bug report for this


For the time being the best workaround (outside of writing your own inject variable plugin) is to run a git command to grab that data from within the script. You'll want something like 

git log -1 --format=%s%n%b <commit hash>

where the commit hash can pulled via the variable 



The only caveat here is that you may need to upload your keys used to connect to Git to the remote agent servers in order to properly run the git commands agains the repository.





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 May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,819 views 0 6
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