working out what fingerprints are used in a build

182 views
Skip to first unread message

Chris Withers

unread,
May 14, 2013, 11:18:21 AM5/14/13
to jenkin...@googlegroups.com
Hi All,

I see I can find out the fingerprints created in a build using:

build.getBuildFingerprints()

First question: How I can go from a Fingerprint instance (as in the
sequence returned build getBuildFingerprints) to the build instances
referenced by that fingerprint?

Second question: how can I go in other direction? I have a Build
instance obtained with:

for (item in Jenkins.instance.items) {
build = build.getLastBuild()
}

How can I find out what fingerprints were used in this build?
I want to know so I can go and find the job that originated the
fingerprinted artifact and get a list of the SCM changes that
contributed to it.

Apologies for the clumsiness above, neither Groovy nor Java are my first
language...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

Dean Yu

unread,
May 14, 2013, 11:56:01 AM5/14/13
to jenkin...@googlegroups.com
Hi Chris,
From a Fingerprint instance, you can call getOriginal() to get a
Fingerprint.BuildPtr object that refers to the source of fingerprint. (Or
null if the fingerprint was generated outside of Jenkins.) You can also
call getJobs() on a Fingerprint object to get a list of job names that
consume the artifact that was produced by the source job.

-- Dean
>--
>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-de...@googlegroups.com.
>For more options, visit https://groups.google.com/groups/opt_out.
>
>


Chris Withers

unread,
May 14, 2013, 2:14:59 PM5/14/13
to jenkin...@googlegroups.com, Dean Yu
Hi Dean,

Thanks, but if I have a build that only used artifacts rather than
generating them, how do I get the fingerprints of those artifacts
starting from a build object?

cheers,

Chris

Dean Yu

unread,
May 14, 2013, 8:45:55 PM5/14/13
to jenkin...@googlegroups.com, Dean Yu
Same way. The Fingerprint class gives you both the originator and the
consumers of the artifact represented by that fingerprint.

-- Dean

Chris Withers

unread,
May 15, 2013, 2:05:51 AM5/15/13
to jenkin...@googlegroups.com, Dean Yu
I don't follow...

If I have a build (ie: AbstractBuild as far as interface goes), how do I
get the Fingerprint object for the fingerprints consumed by that build?

build.getBuildFingerprints() appears to only returns fingerprints for
artifacts created by that build, rather than those consumed by it.

Chris
>>>> Simplistix - Content Management, Batch Processing& Python Consulting
>>>> - http://www.simplistix.co.uk
>>>>
>>>> --
>>>> 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-de...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>
>>>
>>
>> --
>> Simplistix - Content Management, Batch Processing& Python Consulting

Dean Yu

unread,
May 15, 2013, 8:15:08 PM5/15/13
to jenkin...@googlegroups.com
Ah. Sounds like you're working with freestyle or matrix jobs. Those need
to have the "Record fingerprints to track usage" option configured
explicitly in the projects. It doesn't happen automatically like it does
for Maven projects.

-- Dean



On 5/14/13 8:18 AM, "Chris Withers" <ch...@simplistix.co.uk> wrote:

Chris Withers

unread,
May 16, 2013, 4:19:17 AM5/16/13
to Dean Yu, jenkin...@googlegroups.com, Dean Yu
Nope, don't think that's it...

Taking one matrix job as an example, I have "Record fingerprints to
track usage" turned on, but if I do
job.getLastBuild().getBuildFingerprints() on that job, I get [].

However, if I do the following on the job that created the artifacts
used by the matrix build:

build = job.getLastBuild()
for (fp in build.getFingerPrints()) {
println fg.getUsages();
}

...I do see the matrix children that used the artifact.

cheers,

Chris

On 16/05/2013 01:10, Dean Yu wrote:
> Ah. Sounds like you're working with freestyle or matrix jobs. Those need
> to have the "Record fingerprints to track usage" option configured
> explicitly in the projects. It doesn't happen automatically like it does
> for Maven projects.
>
> -- Dean
>
>>>>> -- Dean
>>>>>
>>>>> On 5/14/13 8:18 AM, "Chris Withers"<ch...@simplistix.co.uk> wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I see I can find out the fingerprints created in a build using:
>>>>>>
>>>>>> build.getBuildFingerprints()
>>>>>>
>>>>>> First question: How I can go from a Fingerprint instance (as in the
>>>>>> sequence returned build getBuildFingerprints) to the build instances
>>>>>> referenced by that fingerprint?
>>>>>>
>>>>>> Second question: how can I go in other direction? I have a Build
>>>>>> instance obtained with:
>>>>>>
>>>>>> for (item in Jenkins.instance.items) {
>>>>>> build = build.getLastBuild()
>>>>>> }
>>>>>>
>>>>>> How can I find out what fingerprints were used in this build?
>>>>>> I want to know so I can go and find the job that originated the
>>>>>> fingerprinted artifact and get a list of the SCM changes that
>>>>>> contributed to it.
>>>>>>
>>>>>> Apologies for the clumsiness above, neither Groovy nor Java are my
>>>>>> first
>>>>>> language...
>>>>>>
>>>>>> Chris
>>>>>>
>>>>>> --
>>>>>> Simplistix - Content Management, Batch Processing& Python Consulting
>>>>>> - http://www.simplistix.co.uk
>>>>>>
>>>>>> --
>>>>>> 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-de...@googlegroups.com.
>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Simplistix - Content Management, Batch Processing& Python Consulting
>>>> - http://www.simplistix.co.uk
>>>
>>>
>>
>> --
>> Simplistix - Content Management, Batch Processing& Python Consulting
>> - http://www.simplistix.co.uk
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________

Chris Withers

unread,
May 16, 2013, 4:29:02 AM5/16/13
to Dean Yu, jenkin...@googlegroups.com, Dean Yu
On 16/05/2013 09:19, Chris Withers wrote:
> Nope, don't think that's it...
>
> Taking one matrix job as an example, I have "Record fingerprints to
> track usage" turned on, but if I do
> job.getLastBuild().getBuildFingerprints() on that job, I get [].
>
> However, if I do the following on the job that created the artifacts
> used by the matrix build:
>
> build = job.getLastBuild()
> for (fp in build.getFingerPrints()) {
> println fg.getUsages();
> }
>
> ...I do see the matrix children that used the artifact.

Sorry, to be clear, I'm still looking for a way to get the fingerprint
objects for the artifacts *used* by a job, rather than those produced by it.

build.getFingerPrints() only appears to provide the latter.

What am I missing?

Dean Yu

unread,
May 17, 2013, 4:50:15 PM5/17/13
to Chris Withers, jenkin...@googlegroups.com, Dean Yu
On 5/16/13 1:29 AM, "Chris Withers" <ch...@simplistix.co.uk> wrote:

>On 16/05/2013 09:19, Chris Withers wrote:
>> Nope, don't think that's it...
>>
>> Taking one matrix job as an example, I have "Record fingerprints to
>> track usage" turned on, but if I do
>> job.getLastBuild().getBuildFingerprints() on that job, I get [].
>>
>> However, if I do the following on the job that created the artifacts
>> used by the matrix build:
>>
>> build = job.getLastBuild()
>> for (fp in build.getFingerPrints()) {
>> println fg.getUsages();
>> }
>>
>> ...I do see the matrix children that used the artifact.

I suspect that you are doing getFingerprints on the matrix parent job. If
you did it on the children, you might see something come back from
getUsages.

>
>Sorry, to be clear, I'm still looking for a way to get the fingerprint
>objects for the artifacts *used* by a job, rather than those produced by
>it.
>
>build.getFingerPrints() only appears to provide the latter.
>
>What am I missing?

I don't think you're missing anything. Fingerprint.getOriginal() gives you
the build that produced the artifact[1], and Fingerprint.getUsages() gives
you the builds that consume it.

-- Dean

[1] Technically, getOriginal() is the first build that generated that
artifact checksum, whether or not it's really the producer.


Chris Withers

unread,
May 18, 2013, 7:55:52 PM5/18/13
to jenkin...@googlegroups.com, Dean Yu
On 17/05/2013 21:50, Dean Yu wrote:
>>> However, if I do the following on the job that created the artifacts
>>> used by the matrix build:
>>>
>>> build = job.getLastBuild()
>>> for (fp in build.getFingerPrints()) {
>>> println fg.getUsages();
>>> }
>>>
>>> ...I do see the matrix children that used the artifact.
>
> I suspect that you are doing getFingerprints on the matrix parent job.

Hmm, interesting, what's the "correct" test to use to see if I have a
matrix parent build?

Chris

--

Dean Yu

unread,
May 20, 2013, 1:27:50 PM5/20/13
to jenkin...@googlegroups.com
OK, I think I see where the confusion is stemming from. What's going on is
that the FingerprintAction, which holds the fingerprints that are returned
by build.getBuildFingerprints() is associated with the matrix build (aka,
the matrix parent), but the information in individual fingerprint records
refer to the matrix child runs.

So if you want to figure out what fingerprints are used by the top level
matrix build, you need to go through the usages of the fingerprints, and
record each fingerprint that is used by the matrix child runs of that
parent.

-- Dean
Reply all
Reply to author
Forward
0 new messages