• 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

          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 .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          CHANGES.md
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStepTest.java
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep.java
          basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/config.jelly
          basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/help.html
          support/src/test/java/org/jenkinsci/plugins/workflow/test/steps/WatchYourStep.java
          http://jenkins-ci.org/commit/workflow-plugin/4de61d25f9c32d631baad8f366bff5fecc90d137
          Log:
          [FIXED JENKINS-25570] Added waitUntil step.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep.java basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/config.jelly basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/help.html support/src/test/java/org/jenkinsci/plugins/workflow/test/steps/WatchYourStep.java http://jenkins-ci.org/commit/workflow-plugin/4de61d25f9c32d631baad8f366bff5fecc90d137 Log: [FIXED JENKINS-25570] Added waitUntil step.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStepTest.java
          basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep.java
          basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/config.jelly
          basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/help.html
          http://jenkins-ci.org/commit/workflow-basic-steps-plugin/4658d61fa0effb8f2fb04ae487b2915dccae8683
          Log:
          [FIXED JENKINS-25570] Added waitUntil step.
          Originally-Committed-As: 4de61d25f9c32d631baad8f366bff5fecc90d137

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep.java basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/config.jelly basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/WaitForConditionStep/help.html http://jenkins-ci.org/commit/workflow-basic-steps-plugin/4658d61fa0effb8f2fb04ae487b2915dccae8683 Log: [FIXED JENKINS-25570] Added waitUntil step. Originally-Committed-As: 4de61d25f9c32d631baad8f366bff5fecc90d137

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

              Created:
              Updated:
              Resolved: