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

401 errors on deploy step

Roy Chapman August 23, 2022

We have a Bamboo plan with the following task

npm run prep-deploy && node deploy.js --destination cys –fullDeploy

The deploy.js file contains this section

var config = {

  username: process.env.SAP_USERNAME,

  password: process.env.SAP_PASSWORD,

  path: './dist',

  host: 'https://crmsanproj.svcrm.jlrcloud.com',

  base: '/sap/bc/bsp_dev/sap/zcrm_jlr_dev/',

}

I have the following variables setup at the plan level

env.SAP_USERNAME

env.SAP_PASSWORD

When we execute the command I get these errors

build   22-Aug-2022 15:10:47   Uploading: ./dist/assets/svg/user-landrover.svg STATUS: 401 TIME: 15:10 47

build   22-Aug-2022 15:10:47   to : https://crmsanproj.svcrm.jlrcloud.com/sap/bc/bsp_dev/sap/zcrm_jlr_dev/assets/svg/user-landrover.svg

build   22-Aug-2022 15:10:47   401: null

build   22-Aug-2022 15:10:47   date: Mon, 22 Aug 2022 15:10:47 GMT

build   22-Aug-2022 15:10:47   server: Apache

build   22-Aug-2022 15:10:47   content-type: text/html; charset=utf-8

build   22-Aug-2022 15:10:47   content-length: 1248

build   22-Aug-2022 15:10:47   sap-system: CYS

build   22-Aug-2022 15:10:47   www-authenticate: Basic realm="SAP NetWeaver Application Server [CYS/100]"

build   22-Aug-2022 15:10:47   sap-server: true

build   22-Aug-2022 15:10:47   sap-perf-fesrec: 2427.000000

build   22-Aug-2022 15:10:47   content-security-policy: frame-ancestors self https://*.liveperson.net https://*.svcrm.jlrcloud.com https://*.svcrm.jlrint.com;

build   22-Aug-2022 15:10:47   connection: close


Obviously 401 is an authentication error.  On the server side we are seeing a message indicating an issue with the username, password or client.

The  variables env.SAP_USERNAME & env.SAP_PASSWORD describe the username and password and the section “Basic realm="SAP NetWeaver Application Server [CYS/100” suggests we are passing the client correctly.

At present I am stumped and looking for more debug information.  For example I want to see if the username and password is passed with the npm command?  If there a log or a debug option that would expose this information?

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2022

Hello @Roy Chapman,

Welcome to Atlassian Community!

If you want to use environment variables in Bamboo, you need to adhere to the Bamboo format.

For example, env.SAP_USERNAME would be converted to:

${bamboo.env.SAP_USERNAME}

 or

${bamboo_env_SAP_USERNAME}

..if used in a script task.

More information about how Bamboo prefixes its variables:

Kind regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Roy Chapman August 23, 2022

Eduardo,

We have made these changes to the deploy.js file

var config = {

  username: bamboo.env.SAP_USERNAME,

  password: bamboo.env.SAP_PASSWORD,

  path: './dist',

  host: 'https://crmsanproj.svcrm.jlrcloud.com',

  base: '/sap/bc/bsp_dev/sap/zcrm_jlr_dev/',

}

(previously the entries were prefixed process) When I run the job I now see

error	23-Aug-2022 15:50:06	/home/bamboo/agent1-home/xml-data/build-dir/SVCRM-CJU-JOB1/deploy.js:39
error	23-Aug-2022 15:50:06	  username: bamboo.env.SAP_USERNAME,
error	23-Aug-2022 15:50:06	            ^
error	23-Aug-2022 15:50:06	
error	23-Aug-2022 15:50:06	ReferenceError: bamboo is not defined
error	23-Aug-2022 15:50:06	    at Object.<anonymous> (/home/bamboo/agent1-home/xml-data/build-dir/SVCRM-CJU-JOB1/deploy.js:39:13)
error	23-Aug-2022 15:50:06	    at Module._compile (module.js:653:30)
error	23-Aug-2022 15:50:06	    at Object.Module._extensions..js (module.js:664:10)
error	23-Aug-2022 15:50:06	    at Module.load (module.js:566:32)
error	23-Aug-2022 15:50:06	    at tryModuleLoad (module.js:506:12)
error	23-Aug-2022 15:50:06	    at Function.Module._load (module.js:498:3)
error	23-Aug-2022 15:50:06	    at Function.Module.runMain (module.js:694:10)
error	23-Aug-2022 15:50:06	    at startup (bootstrap_node.js:204:16)
error	23-Aug-2022 15:50:06	    at bootstrap_node.js:625:3

As indicated, the variables are saved in Bamboo they are automatically prefixed with env (for example env.SAP_USERNAME). 

What am I missing?

Roy

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 23, 2022

Thank you @Roy Chapman. Please keep us posted!

Eduardo Alvarenga
Atlassian Support APAC

Roy Chapman August 24, 2022

Eduardo,

I edit the above.  Thoughts?

Roy

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 24, 2022

Hey @Roy Chapman

node.js uses environment variables in the following format:

process.env.<MY_VARIABLE>

So considering the variable in Bamboo is called SAP_USERNAME please try:

process.env.bamboo_SAP_USERNAME

Kind regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Roy Chapman August 24, 2022

Perfect.  Working now

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events