简体   繁体   中英

How to call Jenkins REST API without passing credentials using Java in already logged-in Jenkins?

I have used Jenkins REST API URL to get build status using Java (JAR). It is working successfully by passing user name and password to the API URL. I created a job in Jenkins and using that JAR file to get build status. But, my question is that why should the credential be passed again to API URL as I already logged-in in Jenkins to access the job? The API URL should be accessible without credentials. How to achieve the same?

REST does not persist any session information:

Relevant session data is sent to the receiver by the client in such a way that every packet of information transferred can be understood in isolation, without context information from previous packets in the session.

From https://en.wikipedia.org/wiki/Representational_state_transfer#Statelessness

That means, you must send the credentials with every call by design.

You can have a look at the Java API Client for Jenkins, but it uses the REST API under the hood as well I assume: https://github.com/jenkinsci/java-client-api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM