How to remotely login to a Jenkins server using Java?

前端 未结 2 1075
别跟我提以往
别跟我提以往 2021-01-16 07:59

I\'m trying to login remotely to a Jenkins server using Java.

I didn\'t found some documentation on how this should be securely done.

For my local server usi

2条回答
  •  醉酒成梦
    2021-01-16 08:05

    The Http/Html way is the most cumbersome! I would use jenkins cli or remote api. If you still insist using Java with http then you need to use basic http-authentication and if you plan on trigger more steps inside jenkins use a proper Http/Html Java library like Java-Selenium or HttpUnit.

    Best and simple solution for using http basic auth in Java I found here: Http Basic Authentication in Java using HttpClient?

    • Also check, if your use case can be covered by jenkins cli: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI

      How to use jenkins cli from the command line:

      java -jar jenkins-cli.jar -s yourserver.com help [command]

      The cli works with username & password and also can handle certificates for https connection.

    • Also check the Remote API: https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API

提交回复
热议问题