Bamboo java specs get default branch name - bamboo

I want to set artifactBaranch for auto deployment in bamboo but before that I would like check if that branch is default or not. If that branch is default then I will not set the artifact branch name.
So my question is, is there any way to get default git branch name in bamboo specs using java?

See RssRuntimeContext utility class https://docs.atlassian.com/bamboo-specs-docs/latest/specs.html?java#java-specs-utilities

Related

Gitlab CI Jobs Not Using Latest Template Changes

I've written several pipeline templates that our development teams use in their projects and what I've found is that if I make a change
in a template to fix a bug, when we "retry" a job it doesn't pick up the latest changes from the template. The only way the job will receive the latest
reference to the template is if we push another commit to the developer's project.
Is there a flag or parameter we can set so that it always picks up the latest copy?
Here is what our gitlab yml looks like in the developer projects.
include:
- project: 'ops/awesome-pipelines'
file: 'pipelines/fresh_apps.yml'
Is there a flag or parameter we can set so that it always picks up the
latest copy?
I think the functionality that you are trying is not possible.
Quoting the gitlab docs https://docs.gitlab.com/ee/ci/yaml/index.html#includefile
When the pipeline starts, the .gitlab-ci.yml file configuration
included by all methods is evaluated. The configuration is a snapshot
in time and persists in the database. GitLab does not reflect any
changes to the referenced .gitlab-ci.yml file configuration until the
next pipeline starts.
Template changes are only reflected in new pipelines. The benefit of this is that you can reliably retry jobs and assure that template changes won't change the behavior of a retry.
You don't necessarily need to push another commit, but you will have to start another pipeline (for example, manually running a new pipeline for a branch or MR).

How to override the default plan branch configuration?

Currently we are in the process of migrating our projects from jenkins to bamboo. In this process, I am looking for an option in bamboo plan for a plan branch to be created when a new branch is created in the bitbucket repo and also when pull request is created.
As I see in the branch configuration of a plan, it is possible only to choose one option (new branch or pull request) for plan branch. is there any way where i can choose both options? Can I override the configuration using shell script? our bamboo server is currently running version 6.10.
Bamboo doesn't support multiple options for plan branch creation. What's the reason to have both options?
Before you create PR VCS branch already exists so why option to create plan branch on Bitbucket branch creation is not enough?

How do you see, set, and access variables in IntelliJ so that it can be passed from one plug-in to system properties?

Have a GitHub plug-in in IntelliJ. It knows the branch that is being worked on.
How would you get that branch name and add it into the system properties used when launching a server in the IDE?
This would be the equivalent of something like:
-Dthevariableforbranchnumber=${some.branch.number}
Support for variables in the parameters of the run/debug configurations was added recently, but there is no variable for the branch number.
There is also a related request to add branch to the live templates.
You are welcome to submit a new request at https://youtrack.jetbrains.com/issues/IDEA to provide a variable with the VCS branch for the run configuration.
Still not clear how it will work if the project has multiple VCS roots with different branches.

How can I get the username of the person who triggered a build in Bamboo?

I am trying to integrate Atlassian Bamboo with a CloudFormation template that creates and deploys environments in AWS. One of the tags we add to the VPCs and EC2 instances is the name of the engineer that triggered the build.
I can't find a bamboo variable that contains the name of the user that triggered a build. I found one that has the username of the person who created a release in Jira, but this isn't what I want.
https://confluence.atlassian.com/display/BAMBOO/Bamboo+variables
Is there a way to get this variable?
You are looking for ManualBuildTriggerReason.userName, that will be the name of the person who manually triggered a build but if it was off a trigger this will not be present.
For the name of the person who didn't trigger the build manually but did it through a source code commit then you could probably be:
git log <commitFrom>..<commitTo> --format="%aN <%aE>" --reverse
And then you could use repository.revision.number for the current revision and then repository.previous.revision.number for the previous revision.

Hudson / default Maven

i cannot figure out how to set a default maven. Within a job configuration if you add a Maven Build you have to specify a Version and the goal. The first item in the select box for version is "default". If you have specified other versions under "configure hudson" they will appear there too. However i want all my jobs to use the default. Do i have to set some kind of envoirment variable so hudson knows which maven version is the default one?
Thanks,
kuku
Try setting MAVEN_HOME and adding ${MAVEN_HOME}/bin to your executable PATH.
Interesting, I don't have the default option for maven. So either you have a different Hudson version (I run 1.376) or HUdson recognizes that you have set up maven on the command prompt. In this case the maven installation might not be complete/correct for the user Hudson is running under.
If that doesn't help, let us know what OS you are running on.