0

I am trying to create an node in the Jenkins slave using bash script through automation inside the bash script i need to pass the some environment variables but throwing an error bad substitution and also tried to pass secrets for authentication but throwing error bas substitution

Bash script:

NODE_NAME=${env.NODE_NAME}
LABELS=${env.labelName}


cat <<-EOF | java -jar jenkins-cli.jar -s https://localhost:8080/jenkins.com -http -auth ${{ secrets.Username }}:${{ secrets.API_Token }} create-node $NODE_NAME
<slave>
<name>${NODE_NAME}</name>
<label>${LABELS}</label>
  <nodeProperties/>
  <userId>${USERID}</userId>
</slave>
EOF

enter image description here

  • https://www.shellcheck.net/ shows some errors in your code. You probably need to put single quote around every `${any key}` that isn't a bash variable – Aserre May 24 '22 at 09:55
  • That's a [useless use of `cat`](https://stackoverflow.com/questions/11710552/useless-use-of-cat) though. – tripleee May 24 '22 at 10:24

0 Answers0