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

Shell redirect causes exit code 0

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Plugin v2.21 and 2.30. Also tested this on several Jenkins of various versions.
    • Similar Issues:

      Description

      Running a `sh()` step that has `&>` or any redirect causes the command to work even if the command should fail. It also doesn't appear that the command is running at all. 

      So `sh('FakeNews &> test.log')` outputs the `command not found` error to the console instead of the file. Creates an empty `test.log` and the build passes even though it should have failed. But `sh('FakeNews')` causes exception FakeNews: command not found. This is a more recent issue (last 4 months or so) didn't see this before that.

      I had originally created this bug as a docker issue but I'm seeing it on our updated AWS instances as well.

        Attachments

          Activity

          shadycuz Levi Blaney created issue -
          shadycuz Levi Blaney made changes -
          Field Original Value New Value
          Summary Shell redirect causes exit code 0 on official docker Jenkins Shell redirect causes exit code 0
          shadycuz Levi Blaney made changes -
          Description When using the official Jenkins docker container `jenkins/jenkins` or `jenkins/jenkins:lts`, running a `sh()` step that has `&>` causes the command work even if the command should fail. It also doesn't appear that the command is running at all. 

          So `sh('notacommand &> test.log')` outputs the `command not found` error to the console instead of the file. Creates an empty `test.log` and the build passes even though it should have failed.
          Running a `sh()` step that has `&>` or any redirect causes the command to work even if the command should fail. It also doesn't appear that the command is running at all. 

          So `sh('notacommand &> test.log')` outputs the `command not found` error to the console instead of the file. Creates an empty `test.log` and the build passes even though it should have failed.

          I had originally created this bug as a docker issue but I'm seeing it on our updated AWS instances as well.
          shadycuz Levi Blaney made changes -
          Description Running a `sh()` step that has `&>` or any redirect causes the command to work even if the command should fail. It also doesn't appear that the command is running at all. 

          So `sh('notacommand &> test.log')` outputs the `command not found` error to the console instead of the file. Creates an empty `test.log` and the build passes even though it should have failed.

          I had originally created this bug as a docker issue but I'm seeing it on our updated AWS instances as well.
          Running a `sh()` step that has `&>` or any redirect causes the command to work even if the command should fail. It also doesn't appear that the command is running at all. 

          So `sh('FakeNews &> test.log')` outputs the `command not found` error to the console instead of the file. Creates an empty `test.log` and the build passes even though it should have failed. But `sh('FakeNews')` causes exception FakeNews: command not found. This is a more recent issue (last 4 months or so) didn't see this before that.

          I had originally created this bug as a docker issue but I'm seeing it on our updated AWS instances as well.

            People

            • Assignee:
              Unassigned
              Reporter:
              shadycuz Levi Blaney
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: