Share via


Jenkins variable is not accessible in powershell script

Question

Wednesday, June 5, 2019 11:08 AM

I have a jenkins pipeline script as below. But the echo statement inside powershell is not printing the value.

       script {
            def myvar = "myname"

            powershell '''
                echo "$myvar"
            '''
        }

If I have powershell command inside """ then it is working. How can I get the value printed in my script with '''. Thanks in advance

All replies (2)

Wednesday, June 5, 2019 11:24 AM

This is not a Jenkins forum.  You need to ask Jenkins specific questions in a Jenkins forum.

\(ツ)_/


Wednesday, June 5, 2019 11:26 AM

Follow the instructions here: https://hodgkins.io/automating-with-jenkins-and-powershell-on-windows-part-1

\(ツ)_/