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

Windows batch command only executing 1st line from list of commands given in bat file

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Critical Critical
    • core
    • Windows 2008 Server R2, Enterprise Edition, x64

      Command given in first line of bat file only executes, rest just gets ignored.
      It is blocking all the Jenkins build jobs.

      Able to see this issue in latest build after getting update.

      Workaround - need to manually write each line of command from bat file in individual build steps for windows batch command.

          [JENKINS-37112] Windows batch command only executing 1st line from list of commands given in bat file

          Oleg Nenashev added a comment -

          Cannot reproduce the issue.
          Would be useful to have some pointers like Jenkins version at least

          Oleg Nenashev added a comment - Cannot reproduce the issue. Would be useful to have some pointers like Jenkins version at least

          Andreas Haferburg added a comment - - edited

          I'm seeing the same behavior on 2.361.4.

          Here's the script I'm trying to run:

          pyenv local 3.6.5
          pyenv version
          echo on
          where python
          python --version
          pip install -r requirements.txt
          python "build-system\Jenkins\build.py"

          Jenkins will run the first line, but then stop running the script. It's as if the script ends there.

          I can comment out the problematic line with `REM`, and then it would run the next line, and stop afterwards. The `echo` is fine. `where` is fine. But any other command, and it will interrupt the script afterwards.

          I can see that it prints in the console that it's simply running a `.bat` file from the temp dir. And that file looks fine to me. Nothing out of the ordinary.

          Does anybody have any idea what I could do to debug this?

          Andreas Haferburg added a comment - - edited I'm seeing the same behavior on 2.361.4. Here's the script I'm trying to run: pyenv local 3.6.5 pyenv version echo on where python python --version pip install -r requirements.txt python "build-system\Jenkins\build.py" Jenkins will run the first line, but then stop running the script. It's as if the script ends there. I can comment out the problematic line with `REM`, and then it would run the next line, and stop afterwards. The `echo` is fine. `where` is fine. But any other command, and it will interrupt the script afterwards. I can see that it prints in the console that it's simply running a `.bat` file from the temp dir. And that file looks fine to me. Nothing out of the ordinary. Does anybody have any idea what I could do to debug this?

          When a batch file calls another batch file, one must use `call other.bat` instead of just `other.bat`. Otherwise execution would simply halt because the batch interpreter doesn't track the call stack.

          See https://stackoverflow.com/questions/4036754/why-does-only-the-first-line-of-this-windows-batch-file-execute-but-all-three-li

          https://stackoverflow.com/questions/5107261/batch-script-stops-after-first-call-to-other-batch-script

           

          Andreas Haferburg added a comment - When a batch file calls another batch file, one must use `call other.bat` instead of just `other.bat`. Otherwise execution would simply halt because the batch interpreter doesn't track the call stack. See https://stackoverflow.com/questions/4036754/why-does-only-the-first-line-of-this-windows-batch-file-execute-but-all-three-li https://stackoverflow.com/questions/5107261/batch-script-stops-after-first-call-to-other-batch-script  

            Unassigned Unassigned
            navalg Naval Gupta
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: