Remote access API

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

Remote access API

Jayalakshmi Nair
Hello all,

I was looking for a lightweight method to get the build details. (As we have a lot of builds and noticed that getBuilds method consumes a lot of time).
I figured out that there is no other approach from the Jenkins methods to get the builds.

Now I am trying to get the build details from $JENKINS_HOME/jobs/$NAME_OF_JOB/api/xml. However ,while trying to read the xml using the url, this throws me a 403 or 401. This can be resolved by authenticating.

Can anyone assist me on how I can obtain the username and password of the currently logged in user in java? Or is there a way to access the job link without authentication?
Or is there any api in java which helps me read the above URL?

Thanks in advance.

-Jayalakshmi

--
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/e4cb9ec0-5bb8-4014-bb3a-428aab6d7ccc%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Remote access API

Matt Sicker
You need to create an API token in your user account to authenticate.

On Thu, May 21, 2020 at 6:20 AM Jayalakshmi Nair
<[hidden email]> wrote:

>
> Hello all,
>
> I was looking for a lightweight method to get the build details. (As we have a lot of builds and noticed that getBuilds method consumes a lot of time).
> I figured out that there is no other approach from the Jenkins methods to get the builds.
>
> Now I am trying to get the build details from $JENKINS_HOME/jobs/$NAME_OF_JOB/api/xml. However ,while trying to read the xml using the url, this throws me a 403 or 401. This can be resolved by authenticating.
>
> Can anyone assist me on how I can obtain the username and password of the currently logged in user in java? Or is there a way to access the job link without authentication?
> Or is there any api in java which helps me read the above URL?
>
> Thanks in advance.
>
> -Jayalakshmi
>
> --
> 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/e4cb9ec0-5bb8-4014-bb3a-428aab6d7ccc%40googlegroups.com.



--
Matt Sicker
Senior Software Engineer, CloudBees

--
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/CAEot4oxBUbsT1k7PW%3DNvWPFrCdJ5-Qh1afQ9%2Bj-HXE9qorSNUA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Remote access API

Markus Winter
In reply to this post by Jayalakshmi Nair
I doubt that using the REST api is faster. Under the hood the getBuilds method is also called. But additionally you have to convert the result to XML, transfer the xml and read it back in.

It is not possible to get the password of any user. That would be a big security issue if this would be possible.

It seems to try to get the build details from within your Jenkins instance (via system groovy?). Maybe you describe what you want to achieve.
You could also loop yourself from the last build and use the getPreviousBuild
or use getBuilds(RangeSet)

On 21.05.2020 13:20, Jayalakshmi Nair wrote:
Hello all,

I was looking for a lightweight method to get the build details. (As we have a lot of builds and noticed that getBuilds method consumes a lot of time).
I figured out that there is no other approach from the Jenkins methods to get the builds.

Now I am trying to get the build details from $JENKINS_HOME/jobs/$NAME_OF_JOB/api/xml. However ,while trying to read the xml using the url, this throws me a 403 or 401. This can be resolved by authenticating.

Can anyone assist me on how I can obtain the username and password of the currently logged in user in java? Or is there a way to access the job link without authentication?
Or is there any api in java which helps me read the above URL?

Thanks in advance.

-Jayalakshmi
--
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/e4cb9ec0-5bb8-4014-bb3a-428aab6d7ccc%40googlegroups.com.

--
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/161e44f7-7344-29d4-7c58-c7d86628208b%40gmx.de.
Reply | Threaded
Open this post in threaded view
|

Re: Remote access API

Martin d'Anjou
In reply to this post by Jayalakshmi Nair

Or is there any api in java which helps me read the above URL?

I have used this library quite successfully: https://github.com/cdancy/jenkins-rest
But you still have to provide the credentials.

Martin 

--
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/4541a17a-de2f-4487-b9a9-f03419d0f986%40googlegroups.com.