Trying to add secrets to GoCD pipeline in code, with docker

184 Views Asked by At

I am hoping that someone can fill in a knowledge gap for me. In my typescript application I have created a pipeline in my code for my build and this is working. However, in my package.json I currently have my username and password hard-coded. I am assuming that I add the username and password to the environment as secure variables? If so, how do I reference them in typescript? I found examples for other environments but not typescript.

"sendToSharePoint": "m365 login --authType password --userName myUserName --password myPassword"

EDIT

The problem seems to be that I am building this through docker and I need to pass through the environment var. Trying to figure out how to do that.

exec: command: bash arguments: - -c - docker run prt-ofg-spet -env USERNAME=$USERNAME npm run-script wholeProcess

1

There are 1 best solutions below

0
AdamCodes716 On

in pipeline file:

  • docker run -e DEPLOY_USER=${DEPLOY_USER} -e DEPLOY_USER_PASSWORD=${DEPLOY_USER_PASSWORD}

in package.json script

"sendToSharePoint": "m365 login --authType password --userName $DEPLOY_USER --password $DEPLOY_USER_PASSWORD "

Still struggling to use secure secrets