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

Add support for managed .bat scripts for Windows

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      For Windows platforms, even if I specify a "custom script", the plugin attempts to execute 'sh' with a path to my .bat file, which fails like so:

      java.io.IOException: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\jobs\echo_test\workspace"): CreateProcess error=2, The system cannot find the file specified
      

      If the plugin simply added another category for Windows Batch scripts, the plugin could instead execute "cmd /c call <path/to/file.bat>".

        Attachments

          Activity

          Hide
          domi Dominik Bartholdi added a comment - - edited

          I don't have a windoz at hand right now, but I think this should already work if you define the very first line of your script like this:

          #!cmd /c call

          This works like a shebang on *nix systems and will cause the plugin to use a custom shell interpreter - in this case "cmd"
          http://en.wikipedia.org/wiki/Shebang_%28Unix%29

          could you have a try with this and let me know?

          Show
          domi Dominik Bartholdi added a comment - - edited I don't have a windoz at hand right now, but I think this should already work if you define the very first line of your script like this: #!cmd /c call This works like a shebang on *nix systems and will cause the plugin to use a custom shell interpreter - in this case "cmd" http://en.wikipedia.org/wiki/Shebang_%28Unix%29 could you have a try with this and let me know?
          Hide
          garen Garen Parham added a comment - - edited

          It would probably work if the temp file created didn't have the extension ".sh" which is either unknown or in my case, was associated with my editor.

          After unassociating my editor with .sh files, running "cmd /c <path/to/foo.sh>" hangs when launched from a non-interactive Jenkins service (the default).

          If I try running "cmd /c <path/to/foo.sh>" manually, it opens up one of those interactive prompts that says "Choose the program you want to use to open this file".

          When testing in the command prompt, renaming foo.sh to foo.cmd and doing "cmd /c foo.cmd" does work.

          Show
          garen Garen Parham added a comment - - edited It would probably work if the temp file created didn't have the extension ".sh" which is either unknown or in my case, was associated with my editor. After unassociating my editor with .sh files, running "cmd /c <path/to/foo.sh>" hangs when launched from a non-interactive Jenkins service (the default). If I try running "cmd /c <path/to/foo.sh>" manually, it opens up one of those interactive prompts that says "Choose the program you want to use to open this file". When testing in the command prompt, renaming foo.sh to foo.cmd and doing "cmd /c foo.cmd" does work.
          Hide
          jramsey Jeremy Ramsey added a comment -

          The same option for groovy files would be nice.

          Show
          jramsey Jeremy Ramsey added a comment - The same option for groovy files would be nice.
          Hide
          domi Dominik Bartholdi added a comment -

          Version 1.0 contains now contains support for Windows Batch.

          Show
          domi Dominik Bartholdi added a comment - Version 1.0 contains now contains support for Windows Batch.

            People

            • Assignee:
              domi Dominik Bartholdi
              Reporter:
              garen Garen Parham
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: