• Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline
    • None

      WatchYourStep (in test sources) is actually similar to something that has been requested: a way to wait until a named file appears in the workspace, or until the content of a file has changed, etc. All these things could be handled by a step like this:

      waitForCond {
          readFile 'flag'
      }
      

      or

      waitForCond {
          readFile('flag') == 'ready'
      }
      

      Roughly similar to retry, it would run its block, and if the block either throws an exception or returns false, it would run it again. Or it might be more intuitive to expect only a boolean return value and force the first example to be written as

      waitForCond {
          try {
              readFile 'flag'
              return true
          } catch (FileNotFoundException _) {
              return false
          }
      }
      

      (Even if an exception is permitted as a synonym for false, InterruptedException should be thrown up.)

      Unlike retry there would not need to be any limit to the number of retries, and there would be an exponentially increasing delay between successive retries: run the first time immediately, then retry after 100ms, then continue to multiply the delay by a factor of 1.3 or something like that (perhaps up to some maximum delay like DurableTaskStep has).

          [JENKINS-25570] Wait-for-condition step

          Jesse Glick created issue -
          Jesse Glick made changes -
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

          Would be nice to have all the conditions of the "Run Condition Plugin" available - maybe the workflow plugin could even use this plugin to implement this feature.

          https://wiki.jenkins-ci.org/display/JENKINS/Run+Condition+Plugin

          Dominik Bartholdi added a comment - Would be nice to have all the conditions of the "Run Condition Plugin" available - maybe the workflow plugin could even use this plugin to implement this feature. https://wiki.jenkins-ci.org/display/JENKINS/Run+Condition+Plugin

          Jesse Glick added a comment -

          Most of those conditions are more easily expressed in workflows using plain Groovy code, so I see no advantage in integrating with that plugin.

          Jesse Glick added a comment - Most of those conditions are more easily expressed in workflows using plain Groovy code, so I see no advantage in integrating with that plugin.

          OK, sounds reasonable - I'm not (yet) into the whole workflow stuff...
          Does one have access from the script to the workspace of a job to e.g. check if a file exists and act according?

          So what I mean: the condition should also be able to check remote conditions.

          Dominik Bartholdi added a comment - OK, sounds reasonable - I'm not (yet) into the whole workflow stuff... Does one have access from the script to the workspace of a job to e.g. check if a file exists and act according? So what I mean: the condition should also be able to check remote conditions.

          Jesse Glick added a comment -

          Does one have access from the script to the workspace of a job to e.g. check if a file exists and act according?

          Yes, see the third example in my original issue description.

          Jesse Glick added a comment - Does one have access from the script to the workspace of a job to e.g. check if a file exists and act according? Yes, see the third example in my original issue description.

          Jesse Glick added a comment -

          Note to self: if deleting WatchYourStep, can also close PR 10.

          Jesse Glick added a comment - Note to self: if deleting WatchYourStep , can also close PR 10 .
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Link New: This issue depends on JENKINS-26148 [ JENKINS-26148 ]
          Jesse Glick made changes -
          Link New: This issue depends on JENKINS-26163 [ JENKINS-26163 ]

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: