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

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

Bruce Strickland September 10, 2015

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
Answer accepted
cbenard1
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.
September 10, 2015

Hi Bruce,

Unfortunately commit messages aren't exposed as variables, here is the bug report for this https://jira.atlassian.com/browse/BAM-11958

 

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 

bamboo.planRepository.<position>.revision

 

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.

 

Thanks!

 

Turner

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events