Indicate changes since last build

78 views
Skip to first unread message

Wouter Slob

unread,
Sep 6, 2018, 9:42:57 AM9/6/18
to Jenkins Users
Hi,

I've got several pipeline and for each pipeline I would like to indicate in the view if the last not failed build was on the latest changes.
In other words: I would like to indicate per pipeline if there are changes not yet build.

I've did a lot of searching, but could only find references to the "Changes Since Last Success Plugin", which does not support pipeline (and is quite out-dated).

Does anybody know of an alternative?

Thnx!
Wouter

Craig Rodrigues

unread,
Sep 6, 2018, 11:14:55 AM9/6/18
to Jenkins Users
If you look at the currentBuild variable ( https://ci.jenkins.io/pipeline-syntax/globals#currentBuild ), it has
a few things you can use:
- previousBuild
- changeSets

You can try playing around with those, and see if you can get the changesets for the current build,
and the previous build.

currentBuild is of type RunWrapper, and you can see the full documentation for those methods here:


If you get something to work, please post a code snippet.
--
Craig

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/eec2945c-025c-488a-8d29-22a4862dbd96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wouter Slob

unread,
Sep 6, 2018, 1:14:40 PM9/6/18
to Jenkins Users
Hi Craig,

thanks for your reply!

It is indeed possible to retrieve changes since the last build by iterating currentBuild.changeSets.

But I'm actually looking for a way to visualize any / the changes since the last build in a Job View.

I would like to indicate in the job that new changes are available that have not been build yet, as a way to visualize that a new build is needed.

Any ideas on that?

Regards,
Wouter

Craig Rodrigues

unread,
Sep 7, 2018, 3:02:41 AM9/7/18
to Jenkins Users
I don't have a good answer for you.  What I would do is:

(1)  Iterate over currentBuild.changeSets
(2)  let prevBuild = currentBuild.previousBuild
(3) iterate over the changesets
(4)  keep going back  to the previousBuild, depending on if currentBuild.resultIsWorseOrEqualTo("UNSTABLE")
(5) gather all the changesets you need, and generate an HTML report: https://www.cloudbees.com/blog/publishing-html-reports-pipeline

If you can find a plugin to do what you want, that would be great, but I can't think of any offhand.
--
Craig

Reply all
Reply to author
Forward
0 new messages