If you have control over the jobs and job triggering, you could add a
parameter to the job that contains a UUID. You can then obtain the uuid
of the builds easily and identify the builds.
Or write your own plugin that adds the UUID as build action on
execution. Something like the Job Run UUID plugin [1] which was never
released.
Parsing HTML is a very bad idea. A small change that changes the layout
of the pages and it will fail. If you want a reliable way to get the
builds use the REST api.
Regards
Markus
[1] https://wiki.jenkins-ci.org/display/JENKINS/Job+Run+UUID+Plugin
On 27.07.2016 09:22, justin hyland wrote:
I'm adding some custom functionality to our Jenkins interface using
some custom JS and jQuery. A function is set to execute when the user
submits a build, and gets redirected to the projects homepage. The JS
needs the build ID of what was just executed to (for example),
retrieve the builds /consoleText/ value. Theres a few different ways I
can think to get it, but I'm not completely confident in any of them.
I've thought of a few ways, and I have some concerns for most of them
1. Instead of relying on a build number for any actions, I could just
use the /lastBuild/ for that job - My concern here would be if
another build gets executed (EG: by another user) right after the
current user submits the build, but before the
/lastBuild/ resources are queried. That could potentially lead to
the JS interacting with the incorrect build
2. Parse the rows in the build history - The problem there is really
the same as the previous one, the first row in the build history
may not be the build that was just executed
EG:
$('div#buildHistory').find('a.model-link').attr('href').match(
/\/job\/(?:.*)\/([0-9]+)\/?/ ) );
3. Parse the permalink item in the permalink list on the project
homepage, immediately after the build, parsing the text value of
the link. This kinda seems to be the most reliable way, but id
like someone to confirm.
EG: $( 'ul.permalinks-list'
).find('a.permalink-link[href="lastBuild/"]').text().match( /Last
build \(#([0-9]+)\),/ ) );
If anyone has any ideas on which they think is the most reliable, that
would help. Or if you have a better/alternative way to get it.
Thanks!
--
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 jenkinsci-dev+unsubscr...@googlegroups.com
<mailto:jenkinsci-dev+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/f78a0a34-059c-4896-a753-fbc65e63c579%40googlegroups.com
<https://groups.google.com/d/msgid/jenkinsci-dev/f78a0a34-059c-4896-a753-fbc65e63c579%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/5a4fdbf4-1a5b-bd54-a4cf-a2d1ceccb251%40gmx.de.
For more options, visit https://groups.google.com/d/optout.