Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51667

Missing Jenkins API support for reading fingerprints of pipeline build

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • core, pipeline
    • None

      Pipeline builds are able to record Jenkins fingerprints and those can be accessed with the Web UI of a particular build.

      However they are not accesible via Jenkins api, which prevents using them by any automated tools.

      The reason for this is that FingerprintAction is not annotated with ExportedBean and the api does not publish it directly. Instead AbstractBuild has a method getBuildFingerprints which is @Exported as fingerprint with visibility -1. This way the developer excludes them from standard view but it is accesible via tree parameter. See https://issues.jenkins-ci.org/browse/JENKINS-10481 for reference.

      Since WorkflowRun does not inherit from AbstractBuild it does not inherit this method and the fingerprints are not accesible.

      Therefore could you please just add a similar method to WorkflowRun to make fingerprints accessible? 
      The alternative would be to make FingerprintsAction exported directly, but maybe this is not wanted.

          [JENKINS-51667] Missing Jenkins API support for reading fingerprints of pipeline build

          Oleg Nenashev added a comment -

          The method could be promoted to the Run level in directly the core (may also need renaming).
          LocationChanged() handler for fingerprints could be also generalized then: https://github.com/jenkinsci/jenkins/blob/d4737b2b60438ce0e3cb7a8a6f26675f7c880914/core/src/main/java/hudson/model/Fingerprint.java#L829-L836

          Anyway, it looks like a newbie-friendly RFE, not a defect. If a pull request is submitted to the core, I will be happy to review it

          Oleg Nenashev added a comment - The method could be promoted to the Run level in directly the core (may also need renaming). LocationChanged() handler for fingerprints could be also generalized then: https://github.com/jenkinsci/jenkins/blob/d4737b2b60438ce0e3cb7a8a6f26675f7c880914/core/src/main/java/hudson/model/Fingerprint.java#L829-L836 Anyway, it looks like a newbie-friendly RFE, not a defect. If a pull request is submitted to the core, I will be happy to review it

          Matthias Schmalz added a comment - I've created https://github.com/jenkinsci/jenkins/pull/3476 Hope it is ok.

          Oleg Nenashev added a comment -

          Released in 2.128

          Oleg Nenashev added a comment - Released in 2.128

          Hari Dara added a comment - - edited

          How are the fingerprints made accessible with this fix? I tried the API mentioned in JENKINS-10481 (i.e., appending depth=2&tree=fingerprint[fileName,hash]{0,}, see this comment) and it didn't work.

          Hari Dara added a comment - - edited How are the fingerprints made accessible with this fix? I tried the API mentioned in  JENKINS-10481 (i.e., appending depth=2&tree=fingerprint [fileName,hash] {0, }, see this comment ) and it didn't work.

          haridsv using exactly your parameters works for me. 

          Something must be different for you. Does your job log contain fingerprints at all? I.e. do you see the fingerprints via UI?

          Matthias Schmalz added a comment - haridsv using exactly your parameters works for me.  Something must be different for you. Does your job log contain fingerprints at all? I.e. do you see the fingerprints via UI?

          Hari Dara added a comment - - edited

          I am using archiveArtifacts with fingerprint: true option and I can see the "See Fingerprints" link on the build page and I can see the dump of "Recorded Fingerprints" when I click on that. However when I follow the REST API link at the bottom and click on the JSON API, I get a full dump of the build that has no fingerprints. I then appended the parameters from the above and just get this response { "_class" : "org.jenkinsci.plugins.workflow.job.WorkflowRun" }. What could be different in my case? I am running Jenkins ver. 2.73.3 with all updated plugins as of now.

          Hari Dara added a comment - - edited I am using archiveArtifacts with fingerprint: true option and I can see the "See Fingerprints" link on the build page and I can see the dump of "Recorded Fingerprints" when I click on that. However when I follow the REST API link at the bottom and click on the JSON API, I get a full dump of the build that has no fingerprints. I then appended the parameters from the above and just get this response { "_class" : "org.jenkinsci.plugins.workflow.job.WorkflowRun" }. What could be different in my case? I am running Jenkins ver. 2.73.3 with all updated plugins as of now.

          Just read above: The fix has been released with 2.128. So the easy answer is that your Jenkins version is too old.

          Matthias Schmalz added a comment - Just read above: The fix has been released with 2.128. So the easy answer is that your Jenkins version is too old.

          Hari Dara added a comment -

          Duh! I read 2.128 as 2.12.8 and assumed that mine is newer. Thanks for pointing out and sorry about the confusion.

          Hari Dara added a comment - Duh! I read 2.128 as 2.12.8 and assumed that mine is newer. Thanks for pointing out and sorry about the confusion.

            Unassigned Unassigned
            matthias_schmalz Matthias Schmalz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: