Details

    • Type: New Feature
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      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).

        Attachments

          Issue Links

            Activity

            Hide
            domi 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

            Show
            domi 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
            Hide
            jglick 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.

            Show
            jglick 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.
            Hide
            domi 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.

            Show
            domi 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.
            Hide
            jglick 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.

            Show
            jglick 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.
            Hide
            jglick Jesse Glick added a comment -

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

            Show
            jglick Jesse Glick added a comment - Note to self: if deleting WatchYourStep , can also close PR 10 .
            Hide
            scm_issue_link 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.

            Show
            scm_issue_link 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.
            Hide
            scm_issue_link 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

            Show
            scm_issue_link 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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: