Defining my own project type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Defining my own project type

Miguelangel Fernandez
Hi everyone,

I have a very specific use case. All my Jenkins users must be allowed to create jobs that do a very specific thing. Not generic jobs. But jobs that are all created from the same template.

I use the Job DSL plugin to create these jobs, and the jobs created all use the same pipeline code.

Now, I'd like to remove the users' permission to create any other type of job except this one. So that when the user clicks "New Item" the Freestyle, Pipeline, Maven, etc options are hidden or disabled and only my new job type can be chosen.

What's the best way to go about this? My plan is as follows:

  • What's the appropriate extension point to define a new job type? Or what's a good plugin to look at to get an idea?
  • How do I disable or hide all other project types? I'm thinking I'll need to define my own Permissions.
  • How can I hook into my existing DSL job so that the creation of my job will fire the seeder I already have?

Thank you,


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/1e0faca8-e698-42ea-8a33-02fbddbb421b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Jesse Glick-4
On Thu, Jan 11, 2018 at 6:02 AM, Miguelangel Fernandez
<[hidden email]> wrote:
> what's a
> good plugin to look at to get an idea?

For what it’s worth: the CloudBees Templates plugin, along with the
Folders Plus plugin, allows precisely your use case. (Templatized jobs
are not a new item type; rather, the template UI conceals the standard
creation and configuration options.)

Writing a similar feature from scratch would be, well, a lot of work.
Most admins would instead just use Job DSL and deny Job/Create and
Job/Configure to regular users, requiring all modifications to be done
as change requests to DSL sources.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2zuZs_TYDrCOrGjh_kd%2Bvt7j4ToPj3Dp7we36JPmO2ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Miguelangel Fernandez
Thank you for the advice, Jesse.
The Templates Plugin is a feature of Cloudbees Jenkins, not a free open-source plugin. I don't have the budget for CloudBees Jenkins so I've started trying my hand at developing my own project type -which is the first of the items I've outlined above. Doing well so far -and having fun at it. I'd appreciate some pointers on implementing the other two:
  • Disable Freestyle, Folder and Pipeline jobs from the "New Item" view.
  • Fire a Job DSL script from my plugin's java code.

Thank you,

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/aa5b98cc-4bd9-4044-afae-82b949f07dc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Daniel Beck

> On 15. Jan 2018, at 16:47, Miguelangel Fernandez <[hidden email]> wrote:
>
> • Disable Freestyle, Folder and Pipeline jobs from the "New Item" view.

https://github.com/daniel-beck/hide-maven-plugin/ does something similar and should be adaptable for this.

But note that this does not mean such projects cannot be created; POSTing a config.xml still works, as does copying existing projects.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/AFEEB00D-4E9E-4D14-9393-B63A6BCB5925%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Jesse Glick-4
Right, you can use `DescriptorVisibilityFilter` if you are in a collegial environment.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0YJiyrd6xPUu3jB4sqPH02qbA7vSxqPJkiomBC89gP9g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Robert Sandell-2
A much more involved alternative would be to implement your own AuthorizationStrategy and deny regular users create permission on specific TopLevelItemdescriptor types.

-V

2018-01-15 17:54 GMT+01:00 Jesse Glick <[hidden email]>:
Right, you can use `DescriptorVisibilityFilter` if you are in a collegial environment.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr0YJiyrd6xPUu3jB4sqPH02qbA7vSxqPJkiomBC89gP9g%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees, Inc.
CloudBees-Logo.png
Twitter: robert_sandell

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CALzHZS0POD%2B%3Dn4bizWY7R%2B5%2B6zNvyMT38iubcayCdPo%3DK%2B6rDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Miguelangel Fernandez
In reply to this post by Miguelangel Fernandez
Great stuff guys.
As Daniel and Jesse suggested I've extended DescriptorVisibilityFilter the same way the Hide Maven Plugin does. This is a great first step.
Now I want to try Robert's idea to see whether I can make this a bit more granular and disable it only for certain user groups.
I had no idea I could do stuff like this with Jenkins, so thank you all of the awesome advice.


--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/397af2fc-be64-4110-87c1-71911c883e48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Defining my own project type

Jesse Glick-4
On Wed, Jan 17, 2018 at 6:22 PM, Miguelangel Fernandez
<[hidden email]> wrote:
> I've extended DescriptorVisibilityFilter the
> same way the Hide Maven Plugin does.

Remember this just hides the link in the GUI. It has no effect on
CLI/REST usages, etc.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3C4CDKPXZbhRhniTkQp56QADbVaHdGJ_jq7m-AS2WRzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.