How to pass Bamboo variable from Linux Bamboo to windows Bamboo Agent
Asked by Devendar Gangapuram:

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


Answers:
author: Shashank Kumar
body: 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\*\***

comments: author: Devendar Gangapuram
body: 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.


author: Shashank Kumar
body: 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\*\***


author: Devendar Gangapuram
body: 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


author: Shashank Kumar
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/310010iC185C51BC2DDCA47/image-size/large?v=v2&px=999 "image.png")

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

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/310012iB780C672946DDCF0/image-size/large?v=v2&px=999 "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\*\***


author: Devendar Gangapuram
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/310040iEA6B2273266103F0/image-size/large?v=v2&px=999 "Deploy-Failed_error-401-Unautherized_Error.PNG")

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


author: Shashank Kumar
body: 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


author: Devendar Gangapuram
body: Yes, using this : **bamboo.IRLGI01_appZ_gi_anypoint_uat_username**

Regards,

Dev G


author: Shashank Kumar
body: 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


author: Devendar Gangapuram
body: 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:  


author: Shashank Kumar
body: Hello [Devendar](https://community.atlassian.com/t5/user/viewprofilepage/user-id/2497518),

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


author: Devendar Gangapuram
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/312281i3593229981FE46AC/image-size/large?v=v2&px=999 "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,


author: Devendar Gangapuram
body: Hi [@Shashank Kumar](/t5/user/viewprofilepage/user-id/4693340) ,

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

Thank you,

Dev G


author: Shashank Kumar
body: 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


Tags: bamboo-administration

deployment

linux

windows