youngmon/atlassian-qna huggingface dataset:
How to deploy on a scheduled trigger only if there is a new build?
Asked by richardrflores1:

I want to schedule a nightly deployment only if there is a new build. Is there a way to do this?

We tried this, but the release plan ends-up redeploying the latest build. Not exactly what we want-- if the build is not new, then don't deploy. Is this possible?


Answers:
author: Rafael Pinto Sperafico
body: Hi [@richardrflores1](/t5/user/viewprofilepage/user-id/3262908) ,

Thank you for your inquire.
> I want to schedule a nightly deployment only if there is a new build. Is there a way to do this?

Yes, it is possible by running a build nightly that will automatically trigger the deployment. If your build is consuming a repository (*Source Code Checkout* task) you can add a trigger to your plan that will [Poll the repository for changes](https://confluence.atlassian.com/bamboo/polling-the-repository-for-changes-289276903.html "Poll the repository for changes") based on a schedule.

If Bamboo detects a change in the source code, a build of your plan is triggered. In this way you may end-up with what you called as *a new build*.

Once you have that in place, you can go to your Deployment Environment and setup [Triggers for deployment environments](https://confluence.atlassian.com/bamboo/triggers-for-deployment-environments-342098622.html "Triggers for deployment environments").

You could also work with REST API calls and scripting, automating the way Bamboo will run builds and deployments. Those scripts could then be called from Jira, Bitbucket Server, Terminal/Command Prompt or any other.

However, getting back to your initial inquire, there is <https://jira.atlassian.com/browse/BAM-14311> - **Scheduled deployments should only run if the latest version is different than what is actually deployed in that environment** in Atlassian Bamboo's issue tracker.

Please, feel free to add any comments and/or become a watcher so you can get its latest updates.

Kind regards,

Rafael
Is it possible to obtain GIT branch name at Bamboo Spec run time?
Asked by Jorie:

I already tried by using jgit:

```
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.Ref;

import java.io.File;
import java.io.IOException;

Repository repository = FileRepositoryBuilder.create(new File("../.git"));
currentBranch = repository.getBranch();
System.out.println("Current branch: " + currentBranch);
```

This unfortunately throws an access denied error.

```
[ERROR] Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.9.2:run (default-cli) on project bamboo-specs-generator: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.9.2:run failed: access denied ("java.lang.RuntimePermission" "getenv.GIT_OBJECT_DIRECTORY") -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.9.2:run (default-cli) on project bamboo-specs-generator: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.9.2:run failed: access denied ("java.lang.RuntimePermission" "getenv.GIT_OBJECT_DIRECTORY")
```

Or maybe someone who knows how to solve the access denied exception?


Answers:
author: james.mckean
body: Did you figure this out? We are running into a similar problem reading environment variables in Java Specs file.

comments: author: Peter Broere
body: In the path where the bamboo specs is executed contains the path name (a bit encoded, e.g. / is encoded as _2F).

So an ugly solution would be to use the path to obtain the branch name (note: no decoding done in this example). Also note that this can break at any bamboo release, since it is not something that is specified.

```
public static final String REPOSITORY_PATH_PREFIX = "repository-";

public static String GetBranch()
{
  String path = Paths.get(".").toAbsolutePath().normalize().toString();
  for (String element : path.split("/"))
  {
    if (element.startsWith(REPOSITORY_PATH_PREFIX))
    {
      return element.split("-", 3)[2].trim();
    }
  }

  return "unknown";
}
```


author: james.mckean
body: That was a good hint. I have it sorta working. It cleanly identifies if I am in develop branch, but I am stumbling on the master branch. Its probably in my setup of my test environment, but for anyone else looking at this, this looks very promising.
How can I create Release Notes in Bamboo Deployment Task?
Asked by fabcrm:

**How can I create Release Notes in Bamboo Deployment Task?**

I want to automatically generate and deploy Release Notes in a Bamboo Deployment Task.

I want to include the Jira and Commits in the Release Notes.

**How can I do this?**


Answers:
author: Alexey Chystoprudov
body: Bamboo doesn't have any task or feature to generate release notes automatically. But if your source of truth is git repository there're several scripts which can help you to generate it from git log.

The main problem here is starting point in your commit graph to process changes between release versions.

You can find several different tools or scripts to help you at GitHub, like <https://github.com/GitTools/GitReleaseNotes>

Another is totally scripted task

<https://blogs.sap.com/2018/06/22/generating-release-notes-from-git-commit-messages-using-basic-shell-commands-gitgrep/>
Cannot get storage tag for a PlanKey which is a job key, plan didn't start
Asked by Aditi Gaikwad:

We are using bamboo on premise server.

Plan was running correctly but all of sudden , I am getting error as "Cannot get storage tag for a PlanKey which is a job key"

Since I don't have access to bamboo database to check if mapping is done or not(storage tag and plan key)

I have created *plan.storageTag* variable in bamboo plan variable section and assigned value which I collected from metadata tab from last build logs.

Then I executed plan and it was working as expected but next day when I tried to execute same plan then its giving same error as before.

Please suggest on this on high priority as this is stopping my deployment.


Answers:
author: Daniel Santos
body: Hi [@Aditi Gaikwad](/t5/user/viewprofilepage/user-id/2406555)

That is a strange problem.  
I'll need to ask you a couple of questions to check if can help you with this problem.

Please share with us:

1. Is this problem happening when multiple plans or just with this specific one?
2. Is it happening with multiple branches of just with a specific one?
3. If you clone this plan does it work as expected?
4. Are you running a new build or rerunning an old one?
5. Can you share a chunk of your **\<Bamboo_Home\>/logs/atlassian-bamboo.log** so we can check this error in a better context?  
   ??Please remove sensitive data before posting part of your logs here.

I hope the answers to those questions will help us to move forward.

comments: author: Aditi Gaikwad
body: 1.Its happening for just one specific plan

2.Its is happening with multiple branches

3.I cloned plan and checked then also it was not working.

4.I have tried both ways.


author: Daniel Santos
body: Hi [@Aditi Gaikwad](/t5/user/viewprofilepage/user-id/2406555)

Thank you for the answers, but I'm afraid we will need to check the DB to solve this one. The logs chuck I asked may help as well.  

As the last resource (considering no DB access), I would try creating a new plan manually with the same configuration just to avoid the issue.
Docker Deployment with Bamboo
Asked by christok:

We are considering the possibility of implementing Docker in our CI pipeline. I'm new to the technology, but understand the basics. I have us to the point where Bamboo can pull a project from source, build the Docker image from the Dockerfile, and run and test that image as a container on the build server.

What is less clear to me is what to do with that image once it's ready for release. With our traditional IIS apps we simply push the build to each of our environments using msdeploy. However, there's not an obvious analogue for Bamboo deployments using Docker.

Any thoughts on best practices for doing this?


Answers:
author: christok
body: Thanks for the response. What I'm looking for is the analogue to msdeploy and I think that's Docker Machine. Again, I'm new to Docker, so still trying to understand the ecosystem.

A Docker Machine plugin could be pretty cool.

comments: author: Daniel Santos
body: Hi [@christok](/t5/user/viewprofilepage/user-id/2583379)

We have a docker task in Bamboo that can simplify running docker containers or building docker images. This is the reference document about this task:

* [Configuring the Docker task in Bamboo - Atlassian Documentation](https://confluence.atlassian.com/bamboo/configuring-the-docker-task-in-bamboo-720411254.html)

I don't think we will have something out of the box specifically for the purpose you need, but if you can do it in terminal with some scripts and docker, you should be able to do in Bamboo using the same strategy.

I suggest you to run some tests with Bamboo, checking our docs and coming back with the blockers you face. It will be easier to help you moving forward.  

<br />


author: Daniel Santos
body: Hi [@christok](/t5/user/viewprofilepage/user-id/2583379)

Thank you for sharing a good picture of where you are now.  
You should be able to reproduce a similar deployment scenario with Bamboo.

I'm not sure if I really understand the problem you are facing. Can you describe the set of steps Bamboo should do to deploy your image?  

The general configuration would be:

1. Have a deployment project with the needed environments.
2. The deployment project will get the image as an artifact or a reference to the registry that the image was uploaded.
3. It will deploy it to each deployment environment.

In case you miss any specific task you can still use a scrip task and put the sequence of command to deploy your image as expected.

Does it make sense? What am I missing from your question?
Bamboo script task puts "/bin" in front of $PATH and causes problems.
Asked by Samuel Santiago:

I am using Bamboo 6.4. I inserted a Script task to compile my project. But due to the fact that "/bin" is inserted in front of the $PATH the wrong g++ / gcc compiler is used and generated errors. I have installed gcc devtoolset-7 and want to use that version of the compiler.

Is this expected behavior of the Script task - insert /bin in front of the $PATH.

To fix this issue, I had to insert this in the Inline Script Body:

*#!/bin/bash*   
*# Bamboo for some reason pust /bin first in PATH, therefore wrong g++ compile used.*   
*# Therefore, have to put path to proper devtoolset first here.*   
export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH:.


Answers:
author: Daniel Santos
body: Hi [@Samuel Santiago](/t5/user/viewprofilepage/user-id/849182)

According to my recent tests Bamboo will not deliberately add the **/bin** folder in your path. I did notice that a remote agent may add the JAVA path to the PATH variable which probably would not be an issue for you.

The PATH and other variables will be inherited as described below:

* **CASE 1 - local agents**   
  They are only different threads and will have the same set of variables available in the parent process who started the Bamboo server.
* **CASE 2 - remote agents**   
  They are a different process and will get the variables from the parent process starting the agent.  
  ??Keep in mind that if your agent starts as a service it will get the variables available for the user starting that service.

<br />

What I would check:

1. Are you running this build in a remote agent?
2. Do you get a different result when using a different agent?
3. If you start an agent from the terminal (not as a service) and the PATH is correctly set, do you get any changes when the script runs in Bamboo?  
   For this one, you need to make sure you restart your agent when you change the variable.

I'll wait for your comments.


Tags: script
Where are plan repository login credentials stored in the database?
Asked by David Mahoney:

I have a user who wants to know all of the Bamboo plans where he has used his login credentials within the plan's repository configuration.

Where is this info stored in the DB? Or is there another way to answer his question?

Thanks.


Answers:
author: Daniel Santos
body: Hi [@LeroyBrown](/t5/user/viewprofilepage/user-id/716612)

That is indeed a good question!  
The table you are looking for is **VCS_LOCATION** . This table has a column called **XML_DEFINITION_DATA**and guess what, it has XML data on it which is not that easy to parse.

The best way I could come with was through these two DB queries:  

**Get plans with this \<NAME\> in their config**

```
SELECT 
   B.FULL_KEY AS PLAN_KEY,
   B.TITLE AS PLAN_TITLE,
   VL.PLUGIN_KEY AS REPOSITORY_TYPE
FROM 
   VCS_LOCATION AS VL
   JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
   JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
   JOIN BUILD_DEFINITION AS BD ON B.BUILD_ID = BD.BUILD_ID
WHERE
   VL.MARKED_FOR_DELETION=FALSE
   AND VL.IS_GLOBAL=FALSE
   AND VL.XML_DEFINITION_DATA LIKE '%<NAME>%'
```

**Get repositories with this \<NAME\> in their config**

```
SELECT
   VL.NAME, 
   VL.PLUGIN_KEY AS REPOSITORY_TYPE
FROM
   VCS_LOCATION AS VL
WHERE
   MARKED_FOR_DELETION=FALSE
   AND IS_GLOBAL=TRUE
   AND VL.XML_DEFINITION_DATA LIKE '%<NAME>%'
```

We also have this improvement request that covers this scenario. It will be great if you can vote on it. It will help us to set our priorities when going over the suggestions we have:

* [\[BAM-12966\] Centralized credential management](https://jira.atlassian.com/browse/BAM-12966)

<br />

I hope those queries can help.

comments: author: David Mahoney
body: That's awesome. Thanks.


author: Daniel Santos
body: I'm glad it helps you =\]
Build a job using a Docker image from a private repository
Asked by David Gard:

Hello,

We're looking at running jobs in Docker containers as opposed to in the agent environment. While it seems pretty easy to set up, I can't see any option for adding credentials for a private repository.

Is it possible to use Docker images from a private repository?

If not, I'd like to feed back that this feature is pretty useless. Most images on Docker hub run as a non-privileged user, meaning that we would not be able to install required packages (such as jq, Octo, and many, many more). To be honest, even if we could install those tools prior to building, having to do it every time would add far more overhead to the Bamboo server in terms of both time and bandwidth.

Thanks,  
David


Answers:
author: Steffen Opel _Utoolity_
body: Unfortunately this is indeed not yet supported - please watch and vote for the following issue to increase Atlassian's priority for closing this notable gap:

* [Add Capability for 'Docker Runner' to connect to private image registry (BAM-19731)](https://jira.atlassian.com/browse/BAM-19731)

Please note that the **workaround** listed there has been discussed in more detail in [how to configure docker runner to authorize with private docker registry](https://community.atlassian.com/t5/Bamboo-questions/how-to-configure-docker-runner-to-authorize-with-private-docker/qaq-p/742279https://community.atlassian.com/t5/Bamboo-questions/how-to-configure-docker-runner-to-authorize-with-private-docker/qaq-p/742279), so if your happen to target the [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/), the last comment by Stephen Leavitt points out that this special case can be nicely addressed via the [Amazon ECR Docker Credential Helper](https://github.com/awslabs/amazon-ecr-credential-helper) meanwhile.

comments: author: David Gard
body: Thanks for your reply,

It's quite disappointing to see that Bamboo have marked this as low priority in the issue you linked and are not actively working to add this vital feature, especially given the rise in rise in popularity of containerisation.

I have added my vote, fingers crossed other do to.

Thanks,  
David
In Bamboo, what is difference between local agent or remote agent?
Asked by luciano_carlomagno_neuralsoft_com:

I create 2 plans, which 1 has 3 scripts that manually create 3 containers. The other create 2 containers with the 'docker addon'.

When i tried to execute both of them simultaneously i cant, it says that i have reached my concurrent build limit.

My license has unlimited local agents, only one remote agent. Why that message??

Can anyone help me with that?

thanks!


Answers:
author: Bastian Stehmann
body: Hi [@luciano_carlomagno_neuralsoft_com](/t5/user/viewprofilepage/user-id/3091553) ,

Local agents are running on the same server like your bamboo. Remote agents are all agents that run on another server.

comments: author: luciano_carlomagno_neuralsoft_com
body: thanks for your reply, but how can i do to select a job to run on the remote agent?


author: Bastian Stehmann
body: Maybe this might help

<https://confluence.atlassian.com/bamboo/dedicating-an-agent-629015108.html>

And this

<https://community.atlassian.com/t5/Bamboo-questions/How-to-assign-a-specific-build-agent-server-for-a-build-plan/qaq-p/353008>

Might help.
Access denied error when running robocopy from the bamboo server.
Asked by Rick Morayniss:

I am running Bamboo on server A(it is also the building agent) after the artifact file is created I am trying to copy it using robocopy to server "B" and I get an access denied error. But if I run it form a standard command prompt, it works fine. I am logged into server "A" when I run it.

The command is pretty straight forward

c:\\Atlassian\\bamboo-home\\xml-data\\build-dir\\FTD-BB-JOB1\\BB_Test\\Artifact \\\\serverB\\c$\\PreDeployment\\


Answers:
author: Jimmy Seddon
body: Hi [@Rick Morayniss](/t5/user/viewprofilepage/user-id/3287752),

Welcome to the Community!

The Bamboo server will attempt to proform operations as whatever account is running the server instance (or the Windows Service on Windows).

Does the user that is running the Bamboo instance have appropriate permissions to execute the robocopy to server B?

I hope that helps!

-James

comments: author: Rick Morayniss
body: Thanks for the reply.

Do you mean my credentials, or the bamboo service credentials(in this case is "Local System Account"


author: Jimmy Seddon
body: Yes, if you are running as local system, you should change that to a service account (or yourself temporarily to prove it will work) that has permissions on both Server A \& B.
Bamboo not found in services.msc
Asked by Nayanatharha:

i couldnt find the bamboo running as a service in services.msc


Answers:
author: anton_komir_cetitec
body: Instruction (<https://confluence.atlassian.com/display/BAMBOO044/Running+Bamboo+service+on+Windows+as+the+local+user>) could be updated: display name from "**Bamboo build server"** to "Atlassian Bamboo Bamboo".


author: Nic Brough -Adaptavist-
body: How did you try to add it as a service?

If you just ran the installer according to the docs, what error did you get when it tried to add it as a service?

comments: author: Nayanatharha
body: the thing is i have already installed in my machine and i want to make it as a service, when i try to access the Installasaservice.bat it simply throws jdk and jre mismatch


author: Nic Brough -Adaptavist-
body: You'll need to adjust your environment so that it points to the right version of Java, the one built into the Jira installation. Set the JAVA_HOME variable to the root of the jre in the Jira installation, and make sure $JAVA_HOME/bin is in the path before the system installed Java, then run the batch file again.
Bamboo VSTest Runner remote agent capabilities
Asked by tkus:

I have*VSTest* tools installed on my remote agent. When using*VSTest Runner* task I got an error "No agents meet this job's requirements". I know that I can define agent capabilities in bamboo-capabilities.properties file in agen't bin folder. For MSBuild it looks like:

```
system.builder.msbuild.MSBuild=C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe
```

What is the expected syntax for VSTest Runner ?


Answers:
author: Daniel Santos
body: Hi [@tkus](/t5/user/viewprofilepage/user-id/632080)

Thinking on this problem and knowing the limation we have to maintain the document with all the possible capabilities, I just wrote this article that might help moving forward.

Can you check it and see if this will help you?  
Any suggestions to improve it are very welcome.

This is the one: [How to configure remote agent capabilities using bamboo-capabilities.properties](https://community.atlassian.com/t5/Bamboo-articles/How-to-configure-remote-agent-capabilities-using-bamboo/ba-p/1125201)

I'll wait for your feedback.

comments: author: tkus
body: Hi [@Daniel Santos](/t5/user/viewprofilepage/user-id/502125)

thank you for a nice article. Unfortunately it doesn't work in my case because I don't have admin rights on a bamboo server (this is due to my company security policy) so I can't view / add / remove agent capabilities.

I only have a full access to the remote agent. Is there any way to obtain the capability name from remote agent side ?


author: Daniel Santos
body: > I only have a full access to the remote agent. Is there any way to obtain the capability name from remote agent side ?

Not that I'm aware of.

<br />

The one you need now is the VSTest Runner, right?

The configuration for this one is the example used in that article.

```
system.builder.vstestconsole.VSTestRunner=<PATH>
```

Is there any other you need me to check for you?


author: tkus
body: Thanks a lot.


author: Daniel Santos
body: You are welcome!


Tags: remote-agent
How can we copy build artifacts for all the projects to a remote server?
Asked by Ramakrishna Kommineni:

I am trying to copy all of my build artifacts to a different server workspace? Any easy way to do it.


Answers:
author: Daniel Santos
body: Hi [@Ramakrishna Kommineni](/t5/user/viewprofilepage/user-id/2403687)

The files you are looking for are located at **\<Bamboo_Home\>/xml-data/artifacts**.

You will need to copy this folder to the new server.  
If both servers are running an in a Linux like environment I would recommend you to use the **rsync** command.

Please also get to know this page:

* [Artifacts in Bamboo Server - Atlassian Documentation](https://confluence.atlassian.com/bamkb/artifacts-in-bamboo-server-829052138.html)

It will help you to understand how artifacts are stored in Bamboo.
Allow Bamboo trigger to be fired to any IP
Asked by Clarizza Campos Ramirez:

Hi, i am trying to use Bamboo triggers to deploy to QA env when a pull request is merged on Bitbucket, since our servers are under firewalls i am receiving following error

<br />

**"Build request for plan \[my_pan\] originated from x.x.x.x,0:0:0:0:0:0:0:0 which is not an allowed address"**

It looks like trigger is receiving an IPv6 instead of IPv4, so, i would like to allow any IP to run my trigger.

Any suggestion?

**NOTE.-** since i am not server admin it could be a little be hard to modify any configuration at OS level


Answers:
author: Steffen Opel _Utoolity_
body: This sounds like you are affected by the long standing but meanwhile addressed lack of IPv6 support in Bamboo, the following bug matches your error message:

* [Bamboo repository IP field does not allow to enter IPv6 addresses (BAM-5712)](https://jira.atlassian.com/browse/BAM-5712)

While BAM-5172 lacks a fix version, the linked [Support IPv6 (BAM-14256)](https://jira.atlassian.com/browse/BAM-14256) issue suggests that this has finally been addressed as of [Bamboo 6.7](https://confluence.atlassian.com/bamboo/bamboo-6-7-release-notes-959795979.html) in October 2018.

Unfortunately this implies that you will need to persuade your server administrator to upgrade Bamboo to a respectively recent version, though BAM-5172 at least lists the following **potential workaround** as a short-term remedy:
> If IPv6 is enabled on the Bamboo server, it can be disabled to workaround this issue.

comments: author: Clarizza Campos Ramirez
body: Hi [@Steffen Opel _Utoolity_](/t5/user/viewprofilepage/user-id/781567)

yes, i already saw this quick fix, but as i mentioned i need to contact server admin in order to do this change, well let me try to go that way.

Thanks.