Problem with environment variable in declarative script

3,671 views
Skip to first unread message

David Aldrich

unread,
Sep 21, 2017, 11:48:43 AM9/21/17
to jenkins...@googlegroups.com

Hi

 

My Jenkinsfile contains:

 

    environment {

       SCRIPTS_PATH="${WORKSPACE}/Tools/Jenkins/PythonScripts"

    }

 

When the script runs I get exception:

 

groovy.lang.MissingPropertyException: No such property: WORKSPACE for class: groovy.lang.Binding

        at groovy.lang.Binding.getVariable(Binding.java:63)

 

How should I correct the syntax?

 

Best regards

 

David

 

Robert Hales

unread,
Sep 21, 2017, 10:27:54 PM9/21/17
to Jenkins Users
Either the syntax checker isn't smart enough, or the variables aren't available like that until you get down into the stages. I am suspecting the former, but just a guess.  

This syntax should work fine, though: 

SCRIPTS_PATH = "${env.WORKSPACE}/tools/Jenkins/PythonScripts"

David Aldrich

unread,
Sep 22, 2017, 3:28:50 AM9/22/17
to jenkins...@googlegroups.com

Thanks Robert, the problem was that I had no top level agent. Works ok now.

 

Best regards

 

David

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/482db132-c078-4815-ada3-e98b8b79404b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

Reply all
Reply to author
Forward
0 new messages