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

shell fails on empty assignments, but shell exit code is 0

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • workflow-cps-plugin
    • None
    • Jenkins 2.89.1 on CentOS 7

      Pipeline fails script when SUB-shell returns non 0 exit code, main shell works fine and returns 0.

      Steps to reproduce:

      very simple pipeline

      node('sddc-controller') {
      stage('Setup foundation') {
      sh """
      source ~/test.sh
      """
      }
      }

      test.sh

      AA="aaaaaaa"

      R="$(echo $AA | tr '[:upper:]' '[:lower:]' | grep 'bb')"

      #export R="$(echo $AA | tr '[:upper:]' '[:lower:]' | grep 'bb')"

      echo "R=$R"

      this fails,

      if 'export R' line is used then script gets executed fine;

      if AA to contain 'bb' then script works tool.

      Expected behavior: should be the same as bash, do not fail R= assignment when grep returns non 0 exit code,

       

       

          [JENKINS-48472] shell fails on empty assignments, but shell exit code is 0

          There are no comments yet on this issue.

            richscze nobody
            kgignatyev Konstantin Ignatyev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: