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
Community moderators have prevented the ability to post new answers.
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
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. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}
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.