Skip to end of metadata
Go to start of metadata

Plugin Information

View Job and Node ownership on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

This plugin is up for adoption. Want to help improve this plugin? Click here to learn more!

Summary

This plugin provides an ownership engine for jobs, folders and nodes. The following features are available:

UI Examples:

  

Plugin documentation

Plugin documentation has been moved to GitHub. You can find it here.

Version history

See the plugin's CHANGELOG page

Contributors

  1. Oleg Nenashev (maintainer)
    • Initial plugin versions (0.1-0.3) have been sponsored by Synopsys Inc., www.synopsys.com

28 Comments

  1. Nice plugin! Thank you!

  2. Haven't been able to get Ownership Macros to work using:

    In "Manage Roles", I created "Project roles" using:

    Role

    Pattern

    <permissions>

    @CoOwner

    .*

    ...

    @Owner

    .*

    ...

    In the project ownership configuration, I have the owner set to a particular user.

    If I login as that user, the user does not receive the <permissions> I set.

    Am I using it right?

    1. Hello, I've added example to the Wiki

      Best regards, Oleg Nenashev

  3. Nice plugin!

    I wonder how I add ownership to existing projects after installing this plugin?

    Making a new project shows "Manage Ownership" in the left menu, but existing projects does not show that.

    Regards

    Per A.

    1. Hello,

      You should enable "Manage ownership" permissions in your security plugin

      Best regards, Oleg Nenashev

  4. When do you plan on adding the functionality to restrict build access on certain slaves based on user/group? Or even assign slaves to specific folders? (Cloudbees: http://jenkins-enterprise.cloudbees.com/docs/user-guide-bundle/foldersplus-sect-controlledslaves.html)

    1. Hello Justin,

      I'm going to add support of build restrictions by the end of this month.

      BTW, there won't be integration with "foldersplus". Feel free to contribute.

      BR, Oleg Nenashev

  5. Hi, Could you please let me know how to access JOB_OWNER, JOB_OWNER_EMAIL via groovy scripts?

    Basically, I'm writing a groovy script which pulls the job owner and mails him with some set of data.

    This script would run on all jobs by getting its job owner.

    Thanks

    1. Hello,

      In the case of builds you can invoke TokenMacro::expand() directly.

      In the case of Scriptler you can use the code snippet below. It returns the same values as TokenMacro.

      import hudson.model.AbstractProject;
      import hudson.model.Job;
      import com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerHelper;
      import com.synopsys.arc.jenkins.plugins.ownership.OwnershipDescription;
      import com.synopsys.arc.jenkins.plugins.ownership.util.OwnershipDescriptionHelper;
      
      String jobName=/**JOB_NAME*/;
      Job job = AbstractProject.resolveForCLI(jobName);
      OwnershipDescription descr = JobOwnerHelper.Instance.getOwnershipDescription(job);
      
      // Print Ownership info
      println "Owner: "+OwnershipDescriptionHelper.getOwnerID(descr);
      println "Owner's e-mail: "+OwnershipDescriptionHelper.getOwnerEmail(descr);
      println "Co-owner IDs: "+OwnershipDescriptionHelper.getCoOwnerIDs(descr);
      println "Co-owner e-mails: "+OwnershipDescriptionHelper.getCoOwnerEmails(descr);
      
      

      BTW, it would be great to have special methods without utilizing of so much classes. I'll add several scripts to Scriptler repository after refactoring.

      1. Thanks a lot Oleg. That works in the groovy script.

        And another question, in a matrix configuration project, I have enabled "Inject ownership variables into environment" and selected "Job Ownership".

        After which in the "Build" section --> "Execute Shell", when I print $JOB_OWNER, it's empty.

        echo ${JOB_OWNER}
        

         --> this prints empty as in the build logs below,

        08:11:12 OwnershipPlugin - Setting JOB_COOWNERS=
        08:11:12 OwnershipPlugin - Setting JOB_COOWNERS_EMAILS=
        08:11:12 OwnershipPlugin - Setting JOB_OWNER=
        08:11:12 OwnershipPlugin - Setting JOB_OWNER_EMAIL=
        08:11:12 $ /bin/sh -xe /tmp/hudson8123950444385875023.sh
        08:11:12 + echo
        08:11:12
        

        Is this an issue or am I missing anything?

        Thanks

        1. Thanks for catching. Seems that almost every plugin starts from bugs in multi-configuration jobs :(

          I've created a bug for this issue: https://issues.jenkins-ci.org/browse/JENKINS-20181

          1. Thanks Oleg. Hoping to get the update soon. :)

            1. Ownership-0.3.1 has been released. It should become available within several hours.

              Please notify me if you experience any issues with multi-configuration jobs.

              1. Thanks a lot Oleg, it works on multi-config projects too.

                After upgrading, jenkins service needed a restart and I could restart only today. So verified this update now and it works.

                Thanks for the plugin.

  6. Hi,

    Is it possible to add automatically the current user as owner to a job if I create it with Jenkins remote access API?

    Thanks!

    1. Yes, it is possible. Just enable the "Setup after creation" option on the global configuration page.

  7. How to use @Me macro to filter job using ownership atrribute?. 

    Thanks

    1. You just need to type it in the View filter's input field. These filters can be enabled in the configuration page of your custom view.

      View filters cannot be configured for the "All" view, but you can assign another view as a default one.

  8. Hi, is there a way to set the primary owner of a job programmatically? I'm running a seeder job using Job DSL plugin to create a folder with a bunch of jobs inside it and I would like to set the primary owner to whomever has fired the seeder job. I tried setting this option in the configuration "Assign job creators as owners", but the result I get is that the created folder's owner is SYSTEM. Is there a way to do this in the seeder's script? If not, can it be done using an API call or some other programmatic way?

     

    1. You can find examples here: https://github.com/oleg-nenashev/demo-jenkins-config-as-code/blob/master/init_scripts/src/main/groovy/DevelopmentFolder.groovy . All types (jobs, folders, agents) have helper classes for that.

      I have never tried how it works with JobDSL though

  9. Hi

    Is it possible to add many primary owners? I want only the primary owners to be able to modify/manage ownership. The secondary owners to be able to edit jobs and an authorized group can only run jobs (but it's not necessary).

  10. Hi Oleg,

     

    I am trying to get things running for a few days now.

    I am working with pipelines on my Jenkins and want to use a combination of Ownership and Emailext. When setting the email recipients to 'ownership.node.secondaryOwnerEmails', it gets always evaluated to an empty array. Also the injection via variable like ${OWNERSHIP,var="JOB_COOWNERS_EMAILS"} does not seem to work in a pipeline, where I always get the message "OWNERSHIP is not supported in this context".

    Do you have any idea how I could get this combination to run?

     

    Thanks!

    1. Yes, Token Macro does not support Pipeline so far.

      Regarding the Global variable, please ensure that you are running within the node() step. Otherwise it will be returning empty values as you say

  11. hi, My project uses a pipeline, I want to open different operations for users with different permissions.

    But this plugin doesn't seem to support the pipeline. Or you have set global variables, I can get the current user's role.

    Looking forward to your reply

     

    1. Please create a JIRA ticket with concrete examples of what you want to do.

      I do not understand the question here

  12. Is it possible to set/update primary/secondary owner by REST API? Or any other way via code?

    1. There is no good API for it so far. It could be added to the plugin relatively easily, because all the code is available in Helper classes. But somebody needs to contribute new API patches