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

How to pass Bamboo variable from Linux Bamboo to windows Bamboo Agent

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2024

Hi,

I have  bamboo variables "${bamboo.appZ_guat_anypoint_uat_username} & ${bamboo.appZ_guat_anypoint_uat_password}" and, defines as project variables. 

And there a deployment script as Bamboo(Linux) task which is running on Bamboo Agent , now trying to pass these above 2 variables to deployment script but unable to read them and deployment is failing with the 'Unauthorized' error. 

 

Please let me now, how to pass Linux Bamboo project variables to Bamboo Agent(Windows)?

 

Thank you,

Dev G

 

1 answer

2 votes
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2024

Hello Dev G,

Welcome to Atlassian Community

Bamboo project variable has a scope within the Project for example Bamboo build plans, Jobs and Tasks can access these variables.

These variables can't be accessed via Deployment projects, there is a open feature request raised for the same, please refer https://jira.atlassian.com/browse/BAM-22039

You can try to define these variables as Global variables and then deployment project should be able to access them, but the downside is that then it would be accesible to all the projects in Bamboo.

https://confluence.atlassian.com/bamboo/shared-credentials-424313357.html

Regards

Shashank kumar

**please don't forget to Accept the answer if your query was answered**

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2024

Thank you Shankar  for the  quick reply.

I forgot to mention you that, I had also tried even defining the  Global variables also, and it gives the same "Unauthorized' error. because of the variable unbale to pass the values. Please let me know, how to achieve this , when Linux Bamboo and Windows Agent case. 

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2024

Hello Dev G,

Sorry I just saw you are talking about Script task and shared credentials can't be used in script task, these are mostly for SCP SSH task etc.

I realised you were asking about syntax of using Global/Project variables in Windows environment, you can use the variables like these

bamboo_planRepository_branchDisplayName

In your case bamboo_appZ_guat_anypoint_uat_username

Read an example here > https://confluence.atlassian.com/bamkb/how-to-control-a-bamboo-build-based-on-the-branch-name-1142230519.html

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

Like # people like this
Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2024

Hi Shashank,

Thank you for the reply.

I have now created shared credentials at  below place. 

  1. Administration 

Overview.

  1. Under Build resources, select Shared credentials.
  2. Selected Username and password, and given name like "AnypointCreds"

Now, how to use this in Deployment script as mentioned  below. 

 

Deploy script:  

-B -Dartifact=ie.appZ.rtf:${bamboo.proj.pom.artefactId}:${bamboo.proj.pom.releaseVersion}:jar -DoutputDirectory=. -Dinclude=org.mule.tools.maven:mule-maven-plugin,org.mule.tools.maven:mule-app-maven-plugin mule:deploy -U -Dmaven.groupId=ie.appZ.rtf -Dmaven.artifactId=${bamboo.proj.pom.artefactId} -Dmaven.version=${bamboo.proj.pom.releaseVersion} -Danypoint.account.username=${bamboo.IRLGI01_appZ_gi_anypoint_uat_username} -Danypoint.account.password=${bamboo.IRLGI01_appZ_gi_anypoint_uat_password} 

 

 

Here, instead of  ${bamboo.IRLGI01_appZ_gi_anypoint_uat_username} & ${bamboo.IRLGI01_appZ_gi_anypoint_uat_password}, I need to replace with the Shared credentials .

 

Please help me to over come this challenge. 

 

 

Thank you,

Dev G

 

 

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2024

Hello Dev G,

Apologies I didn't make it clear before, Shared credentials can't be used in Script tasks, they can be used in other tasks like SCP, SSH etc, example below

image.png

For your case you can define them as Global variable from ⚙️ > Overview > Global variable page like below.

image.png

In your script task you can use them as

-Danypoint.account.username=${bamboo_IRLGI01_appZ_gi_anypoint_uat_username}

-Danypoint.account.password=${bamboo_IRLGI01_appZ_gi_anypoint_uat_password}

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

 

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2024

Hi Shashank, 

Thank you once again for the quick reply.  I have already tried by defining the credentials as Global variables, and values  passing correctly to the script but, it gives 401 -unauthorized error. 

 

Deploy-Failed_error-401-Unautherized_Error.PNG

 

 

We have checked that, the values are correct , but still gives 401 error. please let me know, what causing this unauthorized issue, though we are passing the credentials from the Global variables. 

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2024

Hey Dev G,

Can you confirm one final thing are you using bamboo_IRLGI01_appZ_gi_anypoint_uat_username or bamboo.IRLGI01_appZ_gi_anypoint_uat_username

assuming your global variable name is IRLGI01_appZ_gi_anypoint_uat_username

Regards,

Shashank Kumar

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2024

Yes, using this :  bamboo.IRLGI01_appZ_gi_anypoint_uat_username

 

 

 

 

Regards,

Dev G

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 4, 2024

Hello Dev G,

As you are running your builds in Windows Environment as you have previously mentioned you need to use bamboo_IRLGI01_appZ_gi_anypoint_uat_username

Regards,

shashank kumar

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 14, 2024

Hi Shashank,

When I have tired using like "bamboo_IRLGI01_appZ_gi_anypoint_uat_username", it gives me error: 

Non-parseable eror. 

ERROR] [ERROR] Some problems were encountered while processing the POMs:
13-Mar-2024 15:01:51  [FATAL] Non-parseable POM D:\bamboo-home-agent-AppIRL\xml-data\build-dir\45678593-45744129\arm-deploy-pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen <html>... @1:6)  @ line 1, column 6
13-Mar-2024 15:01:51   @ 
13-Mar-2024 15:01:51  [ERROR] The build could not read 1 project -> [Help 1]
13-Mar-2024 15:01:51  [ERROR]   
13-Mar-2024 15:01:51  [ERROR]   The project  (D:\bamboo-home-agent-AppIRL\xml-data\build-dir\45678593-45744129\arm-deploy-pom.xml) has 1 error
13-Mar-2024 15:01:51  [ERROR]     Non-parseable POM D:\bamboo-home-agent-AppIRL\xml-data\build-dir\45678593-45744129\arm-deploy-pom.xml: Expected root element 'project' but found 'html' (position: START_TAG seen <html>... @1:6)  @ line 1, column 6 -> [Help 2]
13-Mar-2024 15:01:51  [ERROR] 
13-Mar-2024 15:01:51  [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
13-Mar-2024 15:01:51  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
13-Mar-2024 15:01:51  [ERROR] 
13-Mar-2024 15:01:51  [ERROR] For more information about the errors and possible solutions, please read the following articles:

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 14, 2024

Hello Devendar,

I think the original issue with passing credentials is resolved you don't see any authentication error. The problem seems to be with your project POM.xml file.

Will be better if you can open a new question for this and mark this issue as resolved.

Regards,

Shashank Kumar

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 15, 2024

Hi Shashank,

Sorry to say that, I don't agree with you. because the credentials I am passing using global variables are not passing to the scripts using variables ( "bamboo_anypoint_account_clientId_uat" & "bamboo_anypoint_account_client_secret_uat" ) as you suggested me to use is not working. When I pass this type, it is unable to read the script , that is the reason why, it  gives parse error. 

Danypoint.platform.client_id=${bamboo_anypoint_account_clientId_uat} -Danypoint.platform.client_secret=${bamboo_anypoint_account_client_secret_uat}

 

Deploy-Error.PNG

 

If the variables are finey passed, it should display value instead of the variables names in the script like below. 

Danypoint.platform.client_id= DIamsnndednwe21m

Danypoint.platform.client_secret=ndjne893n4dj479

 

Please help to resolve this asap, it is stopping to proceed our tasks. 

 

 

Thank you,

Dev G,

 

 

Devendar Gangapuram
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2024

Hi @Shashank Kumar ,

Please help me on this issue asap, its stopping our works. 

 

 

 

Thank you,

Dev G

 

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2024

Hello Dev G,

At this point I am not exactly clear on the nature of the error and this will require some proper debugging with logs attached which we cannot do over public community forum. 

If you have a valid SEN kindly raise a ticket with Atlassian Support and this will be further looked there.

Regards,

Shashank Kumar

Like Devendar Gangapuram likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events