[JIRA] (JENKINS-38281) Global variables starting with capital letter regression

7 views
Skip to first unread message

jenkins@philgrayson.com (JIRA)

unread,
Sep 16, 2016, 11:01:03 AM9/16/16
to jenkinsc...@googlegroups.com
Phil Grayson created an issue
 
Jenkins / Bug JENKINS-38281
Global variables starting with capital letter regression
Issue Type: Bug Bug
Assignee: Jesse Glick
Attachments: full_stacktrace.txt, workflow-cps-global-lib-2.0.png, workflow-cps-global-lib-2.1.png
Components: workflow-cps-global-lib-plugin
Created: 2016/Sep/16 3:00 PM
Environment: Jenkins: 2.7.4
workflow-cps-global-lib: 2.3
Priority: Major Major
Reporter: Phil Grayson

Problem

Calling a function like `Myvariable.myFunctionName()` from a global library returns the following error;

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method java.lang.Class myFunctionName

This only happens when calling global variables beginning with a capital letter.

Downgrading the workflow-cps-global-lib plugin to v2.0 results in the error going away. Upgrading to v2.1 makes the error appear.

From my point of view this is a regression between v2.0 and v2.1.

Am I not supposed to create global variables starting with a capital letter? This represents a breaking change

Steps to reproduce

1. Setup a global library like;

# directory structure
+- vars
 |   +- one.groovy 
 |   +- Two.groovy 
# in vars/one.groovy
def call() {
  echo "in one()"
}

def fn() {
  echo "In one.fn()"
}
# in vars/Two.groovy
def call() {
  echo "In Two()"
}

def fn() {
  echo "In Two.fn()"
}

2. Load the global library into jenkins (git push)

3. Create a pipeline job with the following pipeline script

one()
one.fn()

Two()
Two.fn()
Expected Output
[Pipeline] echo
in one()
[Pipeline] echo
In one.fn()
[Pipeline] echo
In Two()
[Pipeline] echo
In Two.fn()
Actual Output
in one()
[Pipeline] echo
In one.fn()
[Pipeline] echo
In Two()
[Pipeline] End of Pipeline
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method java.lang.Class fn
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)

        [... truncated - full stack trace attached to ticket ...]
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

jenkins@philgrayson.com (JIRA)

unread,
Sep 16, 2016, 11:13:01 AM9/16/16
to jenkinsc...@googlegroups.com
Phil Grayson updated an issue
Change By: Phil Grayson
h3. Problem


Calling a function like `Myvariable.myFunctionName()` from a global library returns the following error;

{code:java}

org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method java.lang.Class myFunctionName
{code}


This only happens when calling global variables beginning with a capital letter.

Downgrading the workflow-cps-global-lib plugin to v2.0 results in the error going away. Upgrading to v2.1 makes the error appear.

From my point of view this is a regression between v2.0 and v2.1.

Am I not supposed to create global variables starting with a capital letter? This represents a breaking change

in some of my global library code.

h3. Steps to reproduce

1. Setup a global library like;

{code:java}

# directory structure
+- vars
|   +- one.groovy
|   +- Two.groovy
{code}

{code:java}

# in vars/one.groovy
def call() {
  echo "in one()"
}

def fn() {
  echo "In one.fn()"
}
{code}

{code:java}

# in vars/Two.groovy
def call() {
  echo "In Two()"
}

def fn() {
  echo "In Two.fn()"
}
{code}


2. Load the global library into jenkins (git push)

3. Create a pipeline job with the following pipeline script

{code:java}
one()
one.fn()

Two()
Two.fn()
{code}


h5. Expected Output
{code}

[Pipeline] echo
in one()
[Pipeline] echo
In one.fn()
[Pipeline] echo
In Two()
[Pipeline] echo
In Two.fn()
{code}

h5. Actual Output

{code}

in one()
[Pipeline] echo
In one.fn()
[Pipeline] echo
In Two()
[Pipeline] End of Pipeline
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: unclassified method java.lang.Class fn
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)

        [... truncated - full stack trace attached to ticket ...]
{code}


jglick@cloudbees.com (JIRA)

unread,
Oct 4, 2016, 3:17:05 PM10/4/16
to jenkinsc...@googlegroups.com

Am I not supposed to create global variables starting with a capital letter?

No, variable names must start with a lowercase letter. Probably the plugin should enforce this directly.

jenkins@philgrayson.com (JIRA)

unread,
Oct 4, 2016, 5:33:01 PM10/4/16
to jenkinsc...@googlegroups.com

Thank you for the update. I've migrated my affected code since.

I'm happy for this ticket to be closed and I can raise a low priority feature request if you like.

jglick@cloudbees.com (JIRA)

unread,
Oct 5, 2016, 2:29:01 PM10/5/16
to jenkinsc...@googlegroups.com

Can just leave this for the robustness fix.

jglick@cloudbees.com (JIRA)

unread,
Feb 10, 2017, 4:03:02 PM2/10/17
to jenkinsc...@googlegroups.com

vivek.pandey@gmail.com (JIRA)

unread,
Nov 16, 2018, 11:45:02 AM11/16/18
to jenkinsc...@googlegroups.com
Vivek Pandey updated an issue
Change By: Vivek Pandey
Labels: robustness triaged-2018-11
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages