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

Creating a Git TAG In bamboo in JAVA

Ariel Rosa February 9, 2015

Hello guys,


I'm trying to create a plugin for Bamboo in JAVA where whenever there's a complete build, the plugin automatically creates a Git TAG of that build code.

I have the listener up and running, but I can't find the code to create the TAG.
Any of you guys know how? Or any tutorials with TAGs throught JAVA that you guys can share?

Kind regards 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2015

Hello Ariel,

Thank you for your question.

Have you considered running an exec() with the git tag command?

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Ariel Rosa February 10, 2015

Hey there Rafael, thanks for taking the time to answer this. The thing is, which is the Git TAG command in JAVA? hehe I've been looking for this for a while now, but could not find it. :(

rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 11, 2015

Hello Ariel, You could run java.lang.Runtime.exec(String command). The java.lang.Runtime.exec(String command) method executes the specified string command in a separate process. This is a convenience method. An invocation of the form exec(command) behaves in exactly the same way as the invocation exec(command, null, null). package com.sample.runtime.exec; public class SampleRuntimeExec { public static void main(String[] args) { try { // print a message System.out.println("Running git command"); // create a process and execute command Process process = Runtime.getRuntime().exec("git tag -f -a ${bamboo.buildResultKey} -m '${bamboo.planName} build number ${bamboo.buildNumber} passed automated acceptance testing.' ${bamboo.planRepository.revision}"); } catch (Exception ex) { ex.printStackTrace(); } } } — Kind regards, Rafael P. Sperafico Atlassian Support

1 vote
Richard Cross February 10, 2015

A plugin would be useful, but I just run the following in a Script task, which tags the code, and then makes sure that tag was created before exiting successfully.

 

git tag -f \
  -a ${bamboo.buildResultKey} \
  -m "${bamboo.planName} build number ${bamboo.buildNumber} passed automated acceptance testing." \
  ${bamboo.planRepository.revision}


git remote add central ${bamboo.planRepository.repositoryUrl}


git push central ${bamboo.buildResultKey}


git ls-remote \
  --exit-code \
  --tags \
  central ${bamboo.buildResultKey}
TAGS
AUG Leaders

Atlassian Community Events