I am able to provide a user specific permissions in jenkins using the below script
import hudson.security.*
import jenkins.security.*
import jenkins.model.Jenkins
import hudson.model.User
def inst = Jenkins.getInstanceOrNull()
def strategy = inst.getAuthorizationStrategy()
strategy.add(Jenkins.ADMINISTER, “user_id”)
inst.save()
Is it possible to do the reverse i.e. remove permissions using groovy script? Can anyone help me with the script?
The Permission class has an attribute called enabled with associated getters and setters. You can add a permission by setting permission.enabled = true and to remove the permission you should explicitly set permission.enabled = false
The default value for permission.enabled may be different depending on what version of Jenkins you are running. It is best to explicitly set this value either way
Thanks for your reply. I had tried this piece of code. What this piece of code does is remove that entire permission class for all the users in that Jenkins instance. What i am looking for is to remove only one specific permission for one user.