Hi Veena, good news: it doesn't have to be as complex as your example. You don't need to search for the build object. It is already predefined. In System Groovy build step it is 'build'. In Grovy Postbuild plugin there's a 'manager' object and the current build run is 'manager.build' You should have a deeper look at the docs of the plugins.
Here are some examples from one of my Jenkins talks: https://github.com/harry-g/jenkins-scripts/tree/master/examples/GroovyPostbuild 2 of them use badges, so they work with Groovy Postbuild only. See comments in the examples. Have fun, Harald On Thursday, November 29, 2018 at 5:32:42 PM UTC+1, Veena Thomas wrote: > > Hi Björn, > Thank you for your input. I am now able to add badges. Any idea if it is > possible to link similar badges. If I click on a badge can I get the list > of all builds that contain the selected badge? > > On Thursday, November 29, 2018 at 11:10:52 AM UTC+5:30, Björn Pedersen > wrote: >> >> Hi, >> >> you probably should take a look at the Badge Plugin >> <http://wiki.jenkins-ci.org/display/JENKINS/Badge+Plugin> (together with >> Groovy Post Build plugin probably) for adding the labels. Org use the build >> Name Setter plugin to modify the build name if that matches your build >> better. >> >> Björn >> Am Mittwoch, 28. November 2018 16:30:40 UTC+1 schrieb Veena Thomas: >>> >>> I am trying to achieve the following task in Jenkins: 1) Build a maven >>> project 2) When running the test cases I print certain messages to the >>> console output 3) Parse the console output of the build and determine if >>> certain patterns exist in the output 4) If the pattern exists I want to >>> label the build with a specific string >>> >>> I have achieved steps 1-3. I am not able to create a dynamic label and >>> tie it to a build. I have a Groovy script that parses the console output >>> and determines if the pattern exists in the build's output. >>> >>> >>> Bamboo provides this feature to label a build based on regular >>> expressions present in the build's console output. Link - >>> https://confluence.atlassian.com/bamboo0606/using-bamboo/jobs-and-tasks/configuring-jobs/configuring-miscellaneous-settings-for-a-job/configuring-automatic-labeling-of-job-build-results >>> >>> >>> I have gone through various existing Jenkins plugins but have not been >>> successful in achieving this functionality. Is there a plugin to achieve >>> this functionality or can I add additional lines in the Groovy script to >>> create a dynamic build label. Any help is appreciated. >>> >> -- 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-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04228463-c139-446e-87b7-ee85d2010cf7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.