Jenkins variable in groovy script
up vote
1
down vote
favorite
I'd like to use "$WORSKPACE" variable into a groovy file called by jenkins script. But all solutions found on SO failed :
// KO : Wks = build.getEnvironment(listener).get('WORKSPACE')
// KO : Wks = "${WORKSPACE}"
/* KO :
def thr = Thread.currentThread()
def build = thr?.executable
def envVarsMap = build.parent.builds[0].properties.get("WORKSPACE")
*/
// KO : def build = this.getProperty('binding').getVariable('build')
// KO : Wks = "%WORKSPACE%"
Message I got :
Scripts not permitted to use method groovy.lang.GroovyObject setProperty java.lang.String java.lang.Object (JenkinsHelper.name). Administrators can decide whether to approve or reject this signature.
Any idea of code or option to set to allow Jenkins script to work ?
My sample case :
File JenkinsHelper.groovy :
class JenkinsHelper {
def init(String sln) {
Wks = "%WORKSPACE%"
}
}
return new JenkinsHelper();
Call from jenkins script :
def helper = load 'C:/.../test.groovy'
helper.init("Mon SLN")
Thanks :)
variables jenkins groovy environment
add a comment |
up vote
1
down vote
favorite
I'd like to use "$WORSKPACE" variable into a groovy file called by jenkins script. But all solutions found on SO failed :
// KO : Wks = build.getEnvironment(listener).get('WORKSPACE')
// KO : Wks = "${WORKSPACE}"
/* KO :
def thr = Thread.currentThread()
def build = thr?.executable
def envVarsMap = build.parent.builds[0].properties.get("WORKSPACE")
*/
// KO : def build = this.getProperty('binding').getVariable('build')
// KO : Wks = "%WORKSPACE%"
Message I got :
Scripts not permitted to use method groovy.lang.GroovyObject setProperty java.lang.String java.lang.Object (JenkinsHelper.name). Administrators can decide whether to approve or reject this signature.
Any idea of code or option to set to allow Jenkins script to work ?
My sample case :
File JenkinsHelper.groovy :
class JenkinsHelper {
def init(String sln) {
Wks = "%WORKSPACE%"
}
}
return new JenkinsHelper();
Call from jenkins script :
def helper = load 'C:/.../test.groovy'
helper.init("Mon SLN")
Thanks :)
variables jenkins groovy environment
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'd like to use "$WORSKPACE" variable into a groovy file called by jenkins script. But all solutions found on SO failed :
// KO : Wks = build.getEnvironment(listener).get('WORKSPACE')
// KO : Wks = "${WORKSPACE}"
/* KO :
def thr = Thread.currentThread()
def build = thr?.executable
def envVarsMap = build.parent.builds[0].properties.get("WORKSPACE")
*/
// KO : def build = this.getProperty('binding').getVariable('build')
// KO : Wks = "%WORKSPACE%"
Message I got :
Scripts not permitted to use method groovy.lang.GroovyObject setProperty java.lang.String java.lang.Object (JenkinsHelper.name). Administrators can decide whether to approve or reject this signature.
Any idea of code or option to set to allow Jenkins script to work ?
My sample case :
File JenkinsHelper.groovy :
class JenkinsHelper {
def init(String sln) {
Wks = "%WORKSPACE%"
}
}
return new JenkinsHelper();
Call from jenkins script :
def helper = load 'C:/.../test.groovy'
helper.init("Mon SLN")
Thanks :)
variables jenkins groovy environment
I'd like to use "$WORSKPACE" variable into a groovy file called by jenkins script. But all solutions found on SO failed :
// KO : Wks = build.getEnvironment(listener).get('WORKSPACE')
// KO : Wks = "${WORKSPACE}"
/* KO :
def thr = Thread.currentThread()
def build = thr?.executable
def envVarsMap = build.parent.builds[0].properties.get("WORKSPACE")
*/
// KO : def build = this.getProperty('binding').getVariable('build')
// KO : Wks = "%WORKSPACE%"
Message I got :
Scripts not permitted to use method groovy.lang.GroovyObject setProperty java.lang.String java.lang.Object (JenkinsHelper.name). Administrators can decide whether to approve or reject this signature.
Any idea of code or option to set to allow Jenkins script to work ?
My sample case :
File JenkinsHelper.groovy :
class JenkinsHelper {
def init(String sln) {
Wks = "%WORKSPACE%"
}
}
return new JenkinsHelper();
Call from jenkins script :
def helper = load 'C:/.../test.groovy'
helper.init("Mon SLN")
Thanks :)
variables jenkins groovy environment
variables jenkins groovy environment
edited Nov 22 at 15:30
asked Nov 22 at 15:22
NitroDeath666x
84
84
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
This is caused by Jenkins In-process Script Approval as a protection of possible execution of malicious scripts.
If you're an admin, register your pipeline codes in Manage Jenkins > Configure System > Global Pipeline Libraries to avoid this scenario.
References:
https://jenkins.io/doc/book/pipeline/shared-libraries/#global-shared-libraries - Goes in details on writing a library.- https://jenkins.io/doc/book/managing/script-approval
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
add a comment |
up vote
1
down vote
You should use groovy-style environenment variable format, not a Windows-style format:
class JenkinsHelper {
def init(String sln) {
Wks = "${WORSKPACE}"
}
}
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
This is caused by Jenkins In-process Script Approval as a protection of possible execution of malicious scripts.
If you're an admin, register your pipeline codes in Manage Jenkins > Configure System > Global Pipeline Libraries to avoid this scenario.
References:
https://jenkins.io/doc/book/pipeline/shared-libraries/#global-shared-libraries - Goes in details on writing a library.- https://jenkins.io/doc/book/managing/script-approval
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
add a comment |
up vote
1
down vote
accepted
This is caused by Jenkins In-process Script Approval as a protection of possible execution of malicious scripts.
If you're an admin, register your pipeline codes in Manage Jenkins > Configure System > Global Pipeline Libraries to avoid this scenario.
References:
https://jenkins.io/doc/book/pipeline/shared-libraries/#global-shared-libraries - Goes in details on writing a library.- https://jenkins.io/doc/book/managing/script-approval
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
This is caused by Jenkins In-process Script Approval as a protection of possible execution of malicious scripts.
If you're an admin, register your pipeline codes in Manage Jenkins > Configure System > Global Pipeline Libraries to avoid this scenario.
References:
https://jenkins.io/doc/book/pipeline/shared-libraries/#global-shared-libraries - Goes in details on writing a library.- https://jenkins.io/doc/book/managing/script-approval
This is caused by Jenkins In-process Script Approval as a protection of possible execution of malicious scripts.
If you're an admin, register your pipeline codes in Manage Jenkins > Configure System > Global Pipeline Libraries to avoid this scenario.
References:
https://jenkins.io/doc/book/pipeline/shared-libraries/#global-shared-libraries - Goes in details on writing a library.- https://jenkins.io/doc/book/managing/script-approval
answered Nov 24 at 12:53
Quirino Gervacio
89679
89679
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
add a comment |
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
I guess you're right, this means most variables and functions are not allowed and script without admin rights have very poor capacities. I'm suprised. Shared libraries work fine, so I'll try to ask to admin to let me add my lib to be able to compile and test my program.
– NitroDeath666x
Nov 26 at 10:16
add a comment |
up vote
1
down vote
You should use groovy-style environenment variable format, not a Windows-style format:
class JenkinsHelper {
def init(String sln) {
Wks = "${WORSKPACE}"
}
}
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
add a comment |
up vote
1
down vote
You should use groovy-style environenment variable format, not a Windows-style format:
class JenkinsHelper {
def init(String sln) {
Wks = "${WORSKPACE}"
}
}
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
add a comment |
up vote
1
down vote
up vote
1
down vote
You should use groovy-style environenment variable format, not a Windows-style format:
class JenkinsHelper {
def init(String sln) {
Wks = "${WORSKPACE}"
}
}
You should use groovy-style environenment variable format, not a Windows-style format:
class JenkinsHelper {
def init(String sln) {
Wks = "${WORSKPACE}"
}
}
answered Nov 22 at 18:50
yorammi
3,0811524
3,0811524
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
add a comment |
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Doesn't it the same he tried in the sacond line of the example code?
– handras
Nov 22 at 19:19
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Not in the JenkinsHelper.groovy file as he provided in the question, where %WORKSPACE% used
– yorammi
Nov 22 at 19:40
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
Hi, thanks to both of you for your answers. Handras is right, I already tried your answer and it did fail for the same restriction reasons :o( : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String (JenkinsHelper.WORSKPACE). Administrators can decide whether to approve or reject this signature.
– NitroDeath666x
Nov 23 at 10:54
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
If your an administrator you can approve it
– yorammi
Nov 23 at 16:07
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434042%2fjenkins-variable-in-groovy-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown