Run jenkins-cli from Intellij

Answered

I need to start jenkins build job from Intellij, from terminal it works:

sudo java -jar jenkins-cli.jar -s http://localhost:8080/ build job-x/master -s -v


Intellij allows to create jar build configuration, but it doesn't allow to run jar files with administrator rights. So is there way to create build configuration in Intellij which runs jenkins-cli.jar?

Initial problem: need to run and debug jenkins pipeline script.

3 comments
Comment actions Permalink

If you add jenkins-cli.jar to the module classpath, you can create Application run/debug configuration that will start the specified main class from this module dependencies.

0
Comment actions Permalink

Hm, I created run/debug configuration and run it, but have the same problem. Output:

java.io.EOFException
at java.io.DataInputStream.readBoolean(DataInputStream.java:244)
at hudson.cli.Connection.readBoolean(Connection.java:95)
at hudson.cli.CLI.authenticate(CLI.java:567)
at hudson.cli.CLI._main(CLI.java:478)
at hudson.cli.CLI.main(CLI.java:384)

The same exception I get just running jenkins-cli.jar from terminal without sudo. It seems that jenkins-cli.jar need to do some IO operation that's why sudo is required. 

0
Comment actions Permalink

There is no way to run from IDEA with sudo except running IDEA itself with sudo.

Check the exception to see why it's needed, maybe you can workaround it by changing permissions of some files/folders, but this question is already outside of the IDE support scope.

1

Please sign in to leave a comment.