0

Since manually executing steps of my plugin with demo projects takes some time, I'd like to execute it on a separate server using mvn hpi:run. To access Jenkins on my desktop, I'd like to tunnnel e.g. using ssh server -L 8080:server. Unfortunately, I cannot access the server with tunnelling and even on the server itself, curl localhost:8080 works and curl server:8080 does not work (and ssh server works, so it is not a connection problem).

Since ufw is disabled, I assume that the Jenkins which is run by maven usually only listens to 127.0.0.1. To change this, according to https://wiki.jenkins.io/display/JENKINS//Starting+and+Accessing+Jenkins, either setting --httpListenAddress=0.0.0.0 or setting $HTTP_HOST should be possible (https://serverfault.com/questions/408657/how-to-access-jenkins-remotely-on-ubuntu-12-04-server).

Unfortunately, both versions

mvn clean hpi:run -DhttpListenAddress=0.0.0.0
export HTTP_HOST=0.0.0.0 && mvn clean hpi:run

did not succeed. Additionally, I guessed -Djetty.host=0.0.0.0 could work (how to make jetty server accessible from LAN?) since the port of Jenkins can be set using -Djetty.port, but it also did not work:

mvn clean hpi:run -Djetty.host=0.0.0.0

Is there any option to make a Jenkins plugin directly remote accessible when using hpi:run, or is it necessary to deploy it to a local Jenkins server everytime?

David Georg Reichelt
  • 963
  • 1
  • 15
  • 36
  • Please allow me to question this. Why not just run the test in a Jenkins build instead of triggering Jenkins from Maven? – J Fabian Meier Nov 09 '20 at 12:05
  • My goal is to apply my plugin to demo projects, which I can do either in a regular Jenkins instance of or in a Jenkins instance started by `mvn hpi:run`. It is not about just running a unit test, which could be done in a Jenkins build. Thanks for the hint, I changed the beginning to make this clearer. – David Georg Reichelt Nov 09 '20 at 13:15
  • What would be best is mock and test your plugin. But sometimes is not possible, so as you said, a Jenkins instance is required to a real test of plugin. #1 Are you open to another workaround without jenkins? #2 According to the [docs](https://www.jenkins.io/doc/developer/tutorial/run/) hpi:run starts a new jenkins instance. What you want is connect your `mvn hpi:run` to an already jenkins instance? #3 What is your o.s ? – JRichardsz Nov 11 '20 at 23:24
  • #1 I would be open to any workaround easier then what I am currently doing (Ctrl + C for jenkins, `mvn clean package && cp target/project-VERSION.hpi ~/.jenkins/plugins` and `java -jar jenkins.war`). #2 That would be ok, but I would prefer if `hpi:run` would open a new instance and make it publicly accessible. Probably best solution would be to search in https://github.com/jenkinsci/maven-plugin why the `httpListenAddress` is not passed. #3 I am running on Ubuntu (currently 18.04 and 20.04). – David Georg Reichelt Nov 16 '20 at 14:37

1 Answers1

2

Following worked for me:

mvn -Dhost=0.0.0.0 hpi:run 
taleodor
  • 1,849
  • 1
  • 13
  • 15