Re: What is it.badgeActions

2021-03-04 Thread Matt Graham
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 .  
> 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 
>  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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/2d6adfc2-7c18-40dc-95a4-eb5615946befn%40googlegroups.com.


Re: What is it.badgeActions

2021-03-03 Thread Mark Waite


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 .  
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 
 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/606b81cd-76c1-4661-b8df-d538ba195809n%40googlegroups.com.


What is it.badgeActions

2021-03-03 Thread Matt Graham

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]

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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/31744ee5-b683-4c9f-b45f-b617176edd79n%40googlegroups.com.