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

1 vote
Accepted answer

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
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

58 views 3 2
Join discussion

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