I'm trying to add tasks to a java spec job with a for loop, but there doesn't seem to be an easy way to do it.
I was hoping there was something like
job.addTask(new VcsCheckoutTask().addCheckoutOfDefaultRepository());
so that I could add tasks from a loop like this
String[] FILES = "${bamboo.REPOS}".split(",");
job.addTask(
for (int i = 0; i < FILES.length; i++) {new ScriptTask().fileFromPath(FILES[i]));
}
Any ideas?
String[] FILES = "${bamboo.REPOS}".split(",");
ScriptTask[] tasks = Arrays.stream(FILES).map(
file -> new ScriptTask().fileFromPath(file)
).toArray(ScriptTask[]::new);
job.tasks(tasks);
By the way, ${bamboo.REPOS} will not be resolved during specs processing. It should be part of your code
What if I want to combine different types of tasks like ScriptTask and VcsCheckoutTask into a single job with this method?
How would I pull in a Bamboo global variable if that is not going to be resolved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Task[] tasks = new Tasks[10];
tasks[0] = new VcsCheckoutTask...
tasks[1] = new ScriptTask....
job.tasks(tasks)
There's no way to pull in Bamboo variables when Bamboo process specs file. You have to keep that variable at your code, not Bamboo. The reason is that you can run specs processing from your workstation with mvn -Ppublish-specs to update Bamboo server configuration without code commit to repository
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well then the documentation on Java specs isn’t very clear. Specifically this section regarding variables:
https://docs.atlassian.com/bamboo-specs-docs/9.1.1/specs.html?java#variables
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Section about variables you mentioned is about variables available for plans and deployments.
Variables can be used in configuration fields of tasks
Maybe we should improve it to say that variables are not available for Specs logic. All environment available for Specs is reachable through https://docs.atlassian.com/bamboo-specs-docs/9.1.1/specs.html?java#java-specs-utilities
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.