Feedback for local maven workflow in Jenkins Plugin Dev

13 views
Skip to first unread message

Parichay Barpanda

unread,
Apr 14, 2019, 9:16:38 PM4/14/19
to Jenkins Developers
Hi all,

I would like to share my views on local Jenkins Plugin development as an inexperienced programmer.

I was working on 2 different plugins. The second plugin needed a way to depend on the first plugin. There were multiple ways it could be done like:

i) Pushing the artifact to a central(remote) repository but for some reason I did not want it there.

ii) Installing the jar in the local maven but for me it was a complex setup and needs you to make changes during production anyway as jars aren't the best way to control the dependency versions.

iii) Using a Repository Manager like Nexus RM but it is a bit of an overkill if it's just one small project and running a nxrm server is an expensive computational affair. Yet it maybe worth it if you want to cleanly deploy and depend on local plugins without the knowledge of the plugin dependencies management. For me this is the best method if it is just a local or organisational development and not meant for public. I wrote a blog post about setting up a NXRM server here - https://medium.com/@baymac/nexus-repository-manager-setup-for-jenkins-plugin-development-f6246dc669b8.

Each way has it's own trade-offs and it depends on your preference mostly. Stephen has written a nice article about it - https://www.cloudbees.com/blog/playing-trade-offs-maven 

Any suggestions or corrections are welcome.

Thanks.

Regards,
Parichay (baymac)

Jesse Glick

unread,
Apr 15, 2019, 9:09:53 AM4/15/19
to Jenkins Dev
On Sun, Apr 14, 2019 at 9:16 PM Parichay Barpanda
<parichay...@gmail.com> wrote:
> I was working on 2 different plugins.

Private plugins, or hosted in @jenkinsci?

> The second plugin needed a way to depend on the first plugin. There were multiple ways it could be done like:

This is quite routine for plugins hosted in the normal way. You do not
need to do anything special beyond declare the `<dependency>`. You can
even have dependencies on unreleased changes via JEP-305.

> ii) Installing the jar in the local maven but for me it was a complex setup

$ mvn -f first-plugin install

is a complex setup?

Parichay Barpanda

unread,
Apr 15, 2019, 9:23:03 PM4/15/19
to jenkin...@googlegroups.com
Hi jesse,

Thanks for replying.

Both are private plugins.

Installing the plugin using the command as you have suggested is simple enough but I couldn't make it work that way. It compiled successfully but I was unable to import dependencies classes.

I tried another method using the maven install plugin. What I did there can be found here - https://gist.github.com/baymac/6e822204da2c175d10933aedb893dd2a
There was the same problem as installing the plugin from commandlline.

I am confused if "installing the plugin" mean "installing the jar package generated inside the /target directory of the first plugin"?

I will read your JEP when I have some time. 

Regards,
Parichay (baymac)


--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Apr 15, 2019, 9:55:28 PM4/15/19
to Jenkins Dev
On Mon, Apr 15, 2019 at 9:23 PM Parichay Barpanda
<parichay...@gmail.com> wrote:
> Installing the plugin using the command as you have suggested is simple enough but I couldn't make it work that way. It compiled successfully but I was unable to import dependencies classes.

Can you be more specific? This is just normal Maven development
workflow, not specific to Jenkins.

> I tried another method using the maven install plugin. What I did there can be found here - https://gist.github.com/baymac/6e822204da2c175d10933aedb893dd2a

Delete the `maven-install-plugin` configuration. You do not need it.
What you _do_ need is the standard Jenkins plugin parent POM.

https://jenkins.io/doc/developer/tutorial/

> I will read your JEP when I have some time.

Do not bother, it is not likely to be useful in your situation.

Parichay Barpanda

unread,
Apr 15, 2019, 10:13:00 PM4/15/19
to Jenkins Developers
Hi Jesse,

I deleted the `maven-install-plugin` configuration.

And the standard jenkins plugin parent POM is already there.

I ran the following command (the additional params for groupid, artifactid, version are optional).:

mvn install:install-file -Dfile=/home/parichay/gsoc/gitlab-plugin/lib/gitlab-api.jar -DgroupId=io.jenkins.plugins -DartifactId=gitlab-api -Dversion=1.0-SNAPSHOT

Now I am able to depend on this plugin. I tried this before but really do not understand why this was failing. 

Let bygones be bygones.

Thanks for the help, now this definitely looks simpler than setting a NXRM server.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

Jesse Glick

unread,
Apr 15, 2019, 10:28:32 PM4/15/19
to Jenkins Dev
On Mon, Apr 15, 2019 at 10:13 PM Parichay Barpanda
<parichay...@gmail.com> wrote:
> I ran the following command (the additional params for groupid, artifactid, version are optional).:
>
> mvn install:install-file -Dfile=/home/parichay/gsoc/gitlab-plugin/lib/gitlab-api.jar -DgroupId=io.jenkins.plugins -DartifactId=gitlab-api -Dversion=1.0-SNAPSHOT

No, just run

mvn install

as I said before. No parameters.

Parichay Barpanda

unread,
Apr 16, 2019, 12:42:18 AM4/16/19
to Jenkins Developers
Just to clarify what you are suggesting:

1) Run `mvn install` on the first plugin to install it in my local maven repository.
2) Then depend on the first plugin directly in the pom.xml of my second plugin as maven resolves it from local maven repository.

Yeah this works but..

Unfortunately, in my case I had modified maven's settings.xml - https://gist.github.com/baymac/de891c463ccc5316fce475ef87025d19 

Maven checks the upstream jenkins repository (repo.jenkins-ci.org) for dependencies even for my local dependency and of course it isn't found there which gives an error. Although I am not really sure if that is the case because I face this error sometimes and unable to reproduce it again. As of now it works without removing the maven settings.

Regards,
Parichay (baymac)
Reply all
Reply to author
Forward
0 new messages