Feedback for local maven workflow in Jenkins Plugin Dev

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Feedback for local maven workflow in Jenkins Plugin Dev

Parichay Barpanda
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)

--
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/bf7dc0bc-4a24-4d02-9db3-180e9f9fdcaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Jesse Glick-4
On Sun, Apr 14, 2019 at 9:16 PM Parichay Barpanda
<[hidden email]> 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?

--
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/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Parichay Barpanda
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)


On Mon 15 Apr, 2019, 18:39 Jesse Glick <[hidden email] wrote:
On Sun, Apr 14, 2019 at 9:16 PM Parichay Barpanda
<[hidden email]> 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?

--
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/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAD0DWAPyb3XO9KLV3jf5gvHe-XSDVV9edAmhUJ446Kv91B3a9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Jesse Glick-4
On Mon, Apr 15, 2019 at 9:23 PM Parichay Barpanda
<[hidden email]> 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.

--
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/CANfRfr1fP3ZOeftHwf_ddOwrYdT0Bkdv3aPwqKatw2zpBTreXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Parichay Barpanda
In reply to this post by Parichay Barpanda
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.

On Tuesday, April 16, 2019 at 6:53:03 AM UTC+5:30, Parichay Barpanda wrote:
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 - <a href="https://gist.github.com/baymac/6e822204da2c175d10933aedb893dd2a" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbaymac%2F6e822204da2c175d10933aedb893dd2a\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFedXcqO2qrgDwwWyk6km6OPA7F8Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgist.github.com%2Fbaymac%2F6e822204da2c175d10933aedb893dd2a\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFedXcqO2qrgDwwWyk6km6OPA7F8Q&#39;;return true;">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)


On Mon 15 Apr, 2019, 18:39 Jesse Glick <[hidden email] wrote:
On Sun, Apr 14, 2019 at 9:16 PM Parichay Barpanda
<[hidden email]> 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?

--
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 <a href="https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2gM1b2HAo8aBpvaYd2OQA6ertuz5sLzesqwQx7dNmQ8w%40mail.gmail.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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/5c2be6c7-003a-4df3-9acb-aa288d2e9983%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Jesse Glick-4
On Mon, Apr 15, 2019 at 10:13 PM Parichay Barpanda
<[hidden email]> 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.

--
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/CANfRfr1yOxEBxUJ-LcfaBo7Mc2BAccoRq4SVEnE9r4PEdO4%2BOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Feedback for local maven workflow in Jenkins Plugin Dev

Parichay Barpanda
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)

On Tuesday, April 16, 2019 at 7:58:32 AM UTC+5:30, Jesse Glick wrote:
On Mon, Apr 15, 2019 at 10:13 PM Parichay Barpanda
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tK78yDbTCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">parichay...@...> 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.

--
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/b85e3d06-1d55-41c0-ae8d-1c66714f468f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.