[JIRA] (JENKINS-37782) Pipeline Config: Unable to refer to environment var in input string

3 views
Skip to first unread message

andrew.bayer@gmail.com (JIRA)

unread,
Aug 29, 2016, 2:58:01 PM8/29/16
to jenkinsc...@googlegroups.com
Andrew Bayer created an issue
 
Jenkins / Bug JENKINS-37782
Pipeline Config: Unable to refer to environment var in input string
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-config-plugin
Created: 2016/Aug/29 6:57 PM
Environment: Pipeline Config 0.1
Priority: Minor Minor
Reporter: Andrew Bayer

Trying to use env variables in a string for use by input:

pipeline {
    agent label:'master'    
    stages {
        stage('input') {
            input "What is the meaning of $LIFE?"
        } 
    }    
    environment {
        LIFE = "42"
    }    
}

yields an error (sandbox). It would be nice if they could be referred to. Error:

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (org.jenkinsci.plugins.kyoto.ClosureModelTranslator.LIFE)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:181)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor$11.reject(SandboxInterceptor.java:312)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:363)
	at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:24)
	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
	at WorkflowScript.run(WorkflowScript:6)
	at org.jenkinsci.plugins.pipeline.config.ConfigInterpreter.call(/Users/michaelneale/projects/paas/pipeline-config-plugin/src/main/resources/org/jenkinsci/plugins/pipeline/config/ConfigInterpreter.groovy:76)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
	at sun.reflect.GeneratedMethodAccessor255.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:360)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:226)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Aug 29, 2016, 2:59:01 PM8/29/16
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-37782
 
Re: Pipeline Config: Unable to refer to environment var in input string

Yeah, we're only exposing the environment section as environment variables in a withEnv block. I think you may be able to do env.LIFE? Give that a try and let me know. (cc Michael Neale)

mneale@cloudbees.com (JIRA)

unread,
Aug 29, 2016, 6:19:01 PM8/29/16
to jenkinsc...@googlegroups.com

but you can use those vars in shell scripts that are no in a withEnv block?

mneale@cloudbees.com (JIRA)

unread,
Aug 29, 2016, 10:40:04 PM8/29/16
to jenkinsc...@googlegroups.com

Ah, I get you.

OK that works.

Is still slightly confusing but can drop the priority of this. The ' vs " is a little hard to teach.

andrew.bayer@gmail.com (JIRA)

unread,
Sep 16, 2016, 6:57:01 PM9/16/16
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Not A Defect
 
Change By: Andrew Bayer
Status: Open Resolved
Resolution: Not A Defect

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:42 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Not A Defect
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages