Thank you Mark.

I appreciate that. I started to suspect it was something like a plugin as 
we had just updated them and I did check another job. I'll look over that 
link you sent as well. Maybe time to simplify it. 



On Thursday, March 4, 2021 at 4:41:26 PM UTC+11 Mark Waite wrote:

> On Wednesday, March 3, 2021 at 10:22:08 PM UTC-7 Matt  wrote:
>
>>
>> Hi All
>>
>> Im new to jenkins and we have a Groovy script that get successful build 
>> information. Now, we have this bit that iterates over it.badgeActions. 
>> Suddenly Im seeing that badgeAction empty. When I check some old builds, it 
>> has an array of 
>>
>> [hudson.plugins.git.GitTagAction@455c11af]
>>
>>
> Those were probably builds that were run before you installed git plugin 
> 4.5.0 <https://github.com/jenkinsci/git-plugin/releases/tag/git-4.5.0>.  
> The git tag action was removed by default from Jenkins jobs created with 
> git plugin 4.5.0 and later.  Refer to the git plugin documentation for the 
> explanation why the git tag action is not useful 
> <https://plugins.jenkins.io/git/#global-configuration> in almost all 
> cases with Jenkins.
>
> As a quick test, you can enable the "Add git tag actions to jobs" checkbox 
> in the Jenkins global configuration and run your job again.  That should 
> assign the GitTagAction to the new build.
>
> I believe "it" in that groovy loop is used to represent each of the builds 
> in the job, one at a time, while the each loop is iterating over each of 
> the builds.
>
> That looks like the code used in 
> https://stackoverflow.com/questions/27361480/how-can-i-list-successful-jenkins-builds-using-a-groovy-script-in-a-deploy-job
>  
> .  You may want to try the simplification that is offered in comment 3 
> where it suggests
>
> job.builds.findAll{ it.result.toString()=='SUCCESS' && it.badgeActions 
> }.collect{ it.displayName[1..-1] }
>
> Mark Waite
>  
>
>> If I remove the it.badgeActions.each  loop, I see the build numbers. 
>> Firstly, what is is the "it" in def build = it and what the hell is a 
>> badgeAction and should I be concerned its empty?
>>
>> Thanks for any help
>>
>> def job = 
>> jenkins.model.Jenkins.instance.getItemByFullName("${imageTag}/release%2F2.177.0")
>> job.builds.each {
>> def build = it
>>
>>   println "${it.getResult()}"
>> if (it.getResult().toString().equals("SUCCESS")) {
>>   println "${it.badgeActions}"
>>     it.badgeActions.each {
>>       println "${build.displayName}"
>>             builds.add(build.displayName[0..-1])
>>     }
>>     
>>   }
>> }
>>
>> builds.unique();
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/2d6adfc2-7c18-40dc-95a4-eb5615946befn%40googlegroups.com.

Reply via email to