Interview Prep/Jenkins/Jenkinsfile syntax, Groovy & CPS errors

`Warning: A secret was passed to "sh" using Groovy String interpolation, which is insecure. Affected argument(s) used the following variable(s): [NEXUS_PSW]`

IntermediateTroubleshootingJenkinsfile syntax, Groovy & CPS errors
Answer

Likely causes → Double-quoted sh "... ${NEXUS_PSW} ..." interpolates the secret in Groovy.

Diagnose → The warning names the variable; search for it in double-quoted strings.

Fix →

sh 'curl -u "$NEXUS_USR:$NEXUS_PSW" https://nexus/...'

If you also need Groovy variables, pass them through withEnv and keep single quotes.

Prevent → Lint rule in library CI: no ${...PSW} or ${...TOKEN} in double-quoted sh.

All Jenkins questions Roadmap: Jenkins

More on Jenkinsfile syntax, Groovy & CPS errors