Access M2 Release Plugin release permission through groovy

41 views
Skip to first unread message

Tina Danielsson

unread,
Apr 6, 2017, 10:59:42 AM4/6/17
to Jenkins Users
I'm trying to create a groovy script where I set the release permissions fort he M2 Release Plugin. But I can't figure out how to do that. The build in permissons can be accessed via hudson.model.Item.PROPERTY, for example hudson.model.Item.CANCEL. But hudson.model.Item.Release just returns "No such property".

Any ideas on how to access this property?

import hudson.security.*

def job = Hudson.instance.items.find{job -> job.name == "MyJob"}
def authorizationMatrixProperty = job.getProperty(AuthorizationMatrixProperty.class)

authorizationMatrixProperty
?.add(hudson.model.Item.CANCEL,"TESTUSER")
authorizationMatrixProperty
?.add(hudson.model.Item.RELEASE,"TESTUSER")


Logan Twedt

unread,
May 16, 2017, 2:54:52 PM5/16/17
to Jenkins Users
Hi Tina, et all,

I'm also trying to configure the Release permission using a groovy script. I do see that the permission is called CREATE_RELEASE inside an inner class in the m2Release plugin code on GitHub: https://github.com/jenkinsci/m2release-plugin/blob/2f2865cffdd7e4be2a60156f245fabc9508d870b/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseBuildWrapper.java - but I've also tried that Permission name and it doesn't work. Maybe I'm reading that code wrong, not sure.

Has anyone been able to get this working?

-Logan

James Nord

unread,
May 17, 2017, 5:19:49 PM5/17/17
to jenkins...@googlegroups.com
Did you try
    org.jvnet.hudson.plugins.m2release.M2ReleaseBuildWrapper.DescriptorImpl.CREATE_RELEASE ?

/James
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4f03307f-0a28-4af2-8b5a-9af572d80300%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Tina Danielsson

unread,
May 18, 2017, 4:04:14 AM5/18/17
to Jenkins Users
You are my hero James! It worked :)

import hudson.security.*
import org.jvnet.hudson.plugins.m2release.*

def job = Hudson.instance.items.find{job -> job.name == "MyJob"}
def authorizationMatrixProperty = job.getProperty(AuthorizationMatrixProperty.class)

authorizationMatrixProperty?.add(M2ReleaseBuildWrapper.DescriptorImpl.CREATE_RELEASE,"TESTUSER")
Reply all
Reply to author
Forward
0 new messages