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

IvyTrigger is not triggering when modified (already existing) artifact is uploaded to remote artifactory

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • ivytrigger-plugin
    • Jenkins 2.204.5, tested also on version 2.121.1
      IvyTrigger 0.34
      Artifactory 5.2.1

      IvyTrigger trigger output after uploading updated artifact to remote artifactory: 

      Resolving Ivy dependencies.
      	---------------------------------------------------------------------
      	|                  |            modules            ||   artifacts   |
      	|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
      	---------------------------------------------------------------------
      	|        lib       |   1   |   1   |   0   |   0   ||   1   |   1   |
      	---------------------------------------------------------------------
      Resolved dependency tools#testNew;1.0.0-SNAPSHOT 
      ...Checking comparison to previous recorded dependencies.
      Checking previous recording dependency tools#testNew;1.0.0-SNAPSHOT
      ...Checking comparison to previous recorded artifacts.
      Polling complete. Took 0.94 sec.
      No changes.
      

      As new or updated artifact is present, ivy downloaded it (as seen in output - artifacts dwnlded 1), it can be also found on local file system, BUT job is not triggered (modification date comparison should follow, but it doesnt)

       

      Possibly, the reason could be using dependencyNode.isDownloaded() added in 0.34 version (in IvyTriggerEvaluator getMapDependencies method), which is not used to indicate whether the artifacts were downloaded, but the whole module (which is not)...so isDownloaded() is false even if artifact was downloaded, related ivy ticket (old, but described the same in the comment): https://issues.apache.org/jira/browse/IVY-320?jql=project%20%3D%20IVY%20AND%20text%20~%20%22downloaded%22

      Therefore, no comparison of modification date is performed. 

       

      ResultReport update after downloading artifacts, Ivy code snippet: 

      report.getConfigurationReport(dconf).addDependency(dependency,dReport);

      Information about download success of artifacts are stored in ArtifactDownloadReport, which is in dReport.

      Following code produces true, and could be used in plugin instead of dependencyNode.isDownloaded()

      resolveReport.getConfigurationReport(dependencyNode.getRootModuleConfigurations()[0]).getDownloadReports(moduleRevisionId)[0].isDownloaded());
      

      Also, if downloading from remote Artifactory, downloaded artifacts are considered NOT local, and modification date of ArtifactOrigin used is always 0. Related ticket: JENKINS-24950

      Instead, local file from ArtifactDownloadReport could be used:

      File localFile = resolveReport.getConfigurationReport(dependencyNode.getRootModuleConfigurations()[0]).getDownloadReports(moduleRevisionId)[0].getLocalFile; 
      
      localFile.getAbsolutePath();  // C:\...\Jenkins\...\testNew-1.0.0-SNAPSHOT.jar
      localFile.lastModified(); // 1585639081000
      

       

       

          [JENKINS-61801] IvyTrigger is not triggering when modified (already existing) artifact is uploaded to remote artifactory

          Tony Noble added a comment -

          Hi horec123 , thanks for the thorough write-up and proposed solution (and apologies for the delay in looking at it).  One point I'm unsure on (I'm not overly familiar with ivy) - your code only checks the first item of the artifact report - not only for download status, but also for file name and checksum.  I assume that it will be required to loop through the entries for all checks, or is there a specific reason you only check index 0?

          Tony Noble added a comment - Hi horec123 , thanks for the thorough write-up and proposed solution (and apologies for the delay in looking at it).  One point I'm unsure on (I'm not overly familiar with ivy) - your code only checks the first item of the artifact report - not only for download status, but also for file name and checksum.  I assume that it will be required to loop through the entries for all checks, or is there a specific reason you only check index 0?

          Peter Horecny added a comment -

          Hi Tony, yes sure, this was just an example. For each dependency (and its moduleRevisionId) there could be multiple artifacts probably, so it will be needed to loop through the reports. 

          Peter Horecny added a comment - Hi Tony, yes sure, this was just an example. For each dependency (and its moduleRevisionId) there could be multiple artifacts probably, so it will be needed to loop through the reports. 

          Tony Noble added a comment -

          Hi horec123 - I think I have a fix for this, but as I'm not sure I fully understand the underlying mechanisms, could do with someone testing it.  If you could perhaps supply an example job config, or there was some way I could get an updated plugin hpi to you?

          Tony Noble added a comment - Hi horec123 - I think I have a fix for this, but as I'm not sure I fully understand the underlying mechanisms, could do with someone testing it.  If you could perhaps supply an example job config, or there was some way I could get an updated plugin hpi to you?

            stealthdj Tony Noble
            horec123 Peter Horecny
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: