Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37777

Pipeline Config: Unable to assign any non literal to an environment variable

    XMLWordPrintable

Details

    Description

      Should you try anything like:

      environment {
        FOO = blah()
        BAZ = "${blah()}"
      }
      

      you will be rewarded with a stacktrace and a sandbox violation.

      I think it is expected that the environment should be able to set programmatically, limiting it to literals is too restrictive to make it practical.

      org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.jenkinsci.plugins.workflow.cps.CpsClosure2 foo)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:181)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:117)
      	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
      	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
      	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
      	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
      	at WorkflowScript.run(WorkflowScript:21)
      	at org.jenkinsci.plugin
      

      Attachments

        Issue Links

          Activity

            abayer Andrew Bayer added a comment -

            Oops, screwed up and created a new issue, but I like the other one more anyway. =)

            abayer Andrew Bayer added a comment - Oops, screwed up and created a new issue, but I like the other one more anyway. =)
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            People

              abayer Andrew Bayer
              abayer Andrew Bayer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: