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

Can't fail build if condition not met

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Labels:
      None
    • Environment:
      Jenkins: 2.44
      Flexible publish: 0.15.2
    • Similar Issues:

      Description

      Testing that a certain condition is met by running "Execute Shell" in the plugin. Have tried to return 0 and 1 through and the build never fails even though it is configured to do that.

      The condition per se works, meaning that if the condition is met, the specified action is executed.

      If the condition is NOT met, the action isn't executed, as expected.

      However, the build is never marked as failed whatever the outcome of the evaluation of the condition.

      This does NOT fail the build
      {{
      00:00:00.022 ++ find . -name dependency-check-report.xml
      00:00:00.075 + RPT=
      00:00:00.075 ++ test '!' -z ''
      00:00:00.075 + exit
      00:00:00.081 Run condition [Execute Shell] preventing perform for step [[Publish OWASP Dependency-Check analysis results]]
      00:00:00.086 Started calculate disk usage of build
      00:00:00.087 Finished Calculation of disk usage of build in 0 seconds
      00:00:00.089 Started calculate disk usage of workspace
      00:00:00.092 Finished Calculation of disk usage of workspace in 0 seconds
      00:00:00.094 Finished: SUCCESS
      }}

      Nor does this:
      {{00:00:00.023 ++ find . -name dependency_links.txt
      00:00:00.075 + RPT=./info/dependency_links.txt
      00:00:00.076 ++ test '!' -z ./info/dependency_links.txt
      00:00:00.076 + exit
      00:00:00.082 Run condition [Execute Shell] enabling perform for step [[Publish OWASP Dependency-Check analysis results]]
      00:00:00.082 [DependencyCheck] Collecting Dependency-Check analysis files...
      00:00:00.085 [DependencyCheck] Finding all files that match the pattern **/dependency-check-report.xml
      00:00:00.088 [DependencyCheck] Computing warning deltas based on reference build #116
      00:00:00.094 Started calculate disk usage of build
      00:00:00.095 Finished Calculation of disk usage of build in 0 seconds
      00:00:00.097 Started calculate disk usage of workspace
      00:00:00.101 Finished Calculation of disk usage of workspace in 0 seconds
      00:00:00.103 Finished: SUCCESS
      }}

      What do I have to do to fail the build if the condition per se is not met?

        Attachments

          Activity

          Hide
          ikedam ikedam added a comment -

          "evaluation failure" in this context means a more serious error such that Jenkins can't run "Execute shell" at all.
          For example, you tried to execute shell on Windows, bash is broken, the disk is full so that Jenkins can't create a temporary script file, and so on.
          Note: I'm not sure they actually cause evaluation failures, but they are possible situations triggering evaluation failure.
          You can simply run "Execute shell" at the end of build steps, and exiting with non-zero makes the build marked as failure.

          Show
          ikedam ikedam added a comment - "evaluation failure" in this context means a more serious error such that Jenkins can't run "Execute shell" at all. For example, you tried to execute shell on Windows, bash is broken, the disk is full so that Jenkins can't create a temporary script file, and so on. Note: I'm not sure they actually cause evaluation failures, but they are possible situations triggering evaluation failure. You can simply run "Execute shell" at the end of build steps, and exiting with non-zero makes the build marked as failure.

            People

            • Assignee:
              kengra Kent Granström
              Reporter:
              kengra Kent Granström
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: