1

Can any one tell me how to call jenkin parameter value into the groovy script?

Im creating a jenkins job that give permission to a another job for a perticular User.

below pic shows the parameter. i want to call that parameter value into the groovy script

screenshot

please find the script below:

import hudson.model.AbstractProject
import hudson.model.Item
import hudson.security.AuthorizationMatrixProperty
import hudson.security.Permission

AbstractProject proj = hudson.model.Hudson.instance.getItem("testjob")
AuthorizationMatrixProperty authProperty = proj.getProperty(AuthorizationMatrixProperty.class)
Set<String> users = new HashSet<>();
users.add('userid'); // XXX
Map<Permission,Set<String>> newPermissions = new HashMap<Permission, Set<String>>()
newPermissions.put(Item.READ, users)

proj.addProperty(new AuthorizationMatrixProperty(newPermissions))
proj.save()

That parameter value should have to come here userid in the groovy script

can any one tell me how to call jenkin parameter value into the groovy script

Thanks in advance

6
  • Possible duplicate of How to retrieve Jenkins build parameters using the Groovy API? Commented Aug 25, 2016 at 0:02
  • can any one help me out clearly.how to call the string parameter value into script.some one reply me.its bit urgent Commented Aug 25, 2016 at 21:04
  • see the answer by 'inger' in the thread mentioned as duplicate - stackoverflow.com/a/23665470/12704 Commented Aug 25, 2016 at 22:18
  • i did not understand where to keep that line in my code Commented Aug 26, 2016 at 17:57
  • i tried but no user please help me out fast Commented Aug 26, 2016 at 17:58

1 Answer 1

0

I think the asnwer your`e looking for is this: string(name: 'UserID', defaultValue: '',description: 'Enter ID here')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.