Problem
- Jenkins Pipeline (Groovy) and PowerShell use the dollar sign ($) to access or declare variables. When you use dollar sign ($), Jenkins Pipeline will become confused.
Solution
- In powershell section change $yourVaraible to \$yourVaraible
- Example
pipeline { agent any stages{ //.... stage ('PUBLISH') { steps { dir("\\Web\\ds.Invest.WebAPI"){ powershell(script: """ \$env:NODE_OPTIONS = "--openssl-legacy-provider" dotnet publish ds.Invest.WebApi.csproj -c Release --no-build --no-restore """) } } } } }
Reference
- https://stackoverflow.com/a/34489647/20000255
- jenkins - How to escape dollarsign in groovy shell command? - DevOps Stack Exchange
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.