I have a Bamboo build that uses two git repositories -- one for the source code, one for some ancillary information about the project. I have a scheduled task that runs once a day, which builds the source, runs some tests, then automatically commits some metadata to the ancillary repository.
I stumbled across https://confluence.atlassian.com/display/BAMBOO/Using+global,+plan+or+build-specific+variables and it got me wondering... is it possible to get the list of commits / changelog that a bamboo build ran with? I'd love to get this list in to my commits to my ancillary repository.
Hm... I think you should be able to get the SHA of the current/previous build commit. I'd expect you're interested in:
bamboo.repository.revision.number
bamboo.repository.previous.revision.number
variables. I'm not sure why do you need the current build number, but if you need: bamboo.buildNumber - that's the variable I'd use.
Now, the tricky part would be to glue that up in the external script (external script is in my opinion a first option to check, as I agree it will be more viable than writing up java plugin, or seeking for one). The general gist is that you should add a Script Task with inline script looking something alike:
git log ${bamboo.repository.previous.revision.number}..${bamboo.repository.revision.number}
...and do something with the output. Trick is that I'm not 100% sure these variables are working for Git repositories. I reckon they work definitely for SVN repos, but I'm not sure if the are working nicely with Git - I can check that after Easter. The second trick is that as you have two repos definined in your plan you might have to use prefixing syntax like
bamboo.repository.1.revision.number
bamboo.repository.1.previous.revision.number
to tell Bamboo which exactly repository you're interested in - but I can't check ATM what is the syntax (I don't remember :) ) and whether it is necessary at all.
Am I helpful? :)
Hi, I've found an innocently looking button titled "Convert comment to answer" here. Apparently it does exactly what it is named. Though I can't rollback that operation.
<pedant mode>Anyway, feel free to accept the answer now. :)</pedant mode>Or ignore it. I don't mind - happy to hear it was helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Piotr, that's definitely helpful. I'd accept it as the answer, except it's a comment :P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ideally I'd like to get away without needing to write my own plugin -- if there's one available out there aready that does the trick that'd be dandy. But if it comes to writing my own, I wouldn't be averse to plumbing the Java API for the info I wanted.
I suppose the alternative is that I could indeed write an external script to interrogate the git repository, though to make it viable I'd need to be able to get:
* The SHA of the commit for the current build,
* The current build number, and
* The SHA of the commit for the previous build.
Then I could just use Git commands in the script to get the git log I'm after.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris,
Do you consider writing up a Bamboo Task Plugin? or do you want to base on only 'external' Script Tasks, without touching Bamboo Java API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.