Pipeline PowerShell won't execute when there's spaces in the path

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      When creating a job with a space in the name the "powershell" step in a pipeline will hang.

       

      Steps to reproduce:

      1. Create a Pipeline with a space in the name (e.g. "A Space").
      2. Paste in the following pipeline script:
        pipeline {
          agent any
            stages {
              stage ("Stage 1") {
                steps {
                  powershell 'Write-Output "Hello world!"'
        }}}}
      3. Run the build and see it hang on the PowerShell step.

      It looks like it's due to the use of nested double quotes in the command that's called by the plugin, so it's probably ending the string at the wrong point.  I copied the generated PowerShell scripts and tried to execute the command myself and got an error only when spaces and double quotes were used.

      Manual attempt:

      U:\Build Dir>powershell.exe -noninteractive -executionpolicy bypass -command ". "U:\Build Dir\Helper.ps1"; execute-andwriteoutput -mainscript "U:\Build Dir\test.ps1" -logfile "U:\Build Dir\test_log.txt" -resultfile "U:\Build Dir\test_result.txt";"
      . : The term 'U:\Build' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
      the spelling of the name, or if a path was included, verify that the path is correct and try again.
      At line:1 char:3
      + . U:\Build Dir\Helper.ps1; execute-andwriteoutput -mainscript U:\Bui ...
      + ~~~~~~~~
      {{ + CategoryInfo : ObjectNotFound: (U:\Build:String) [], CommandNotFoundException}}
      {{ + FullyQualifiedErrorId : CommandNotFoundException}}execute-andwriteoutput : The term 'execute-andwriteoutput' is not recognized as the name of a cmdlet, function, script
      file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
      and try again.
      At line:1 char:29
      + . U:\Build Dir\Helper.ps1; execute-andwriteoutput -mainscript U:\Bui ...
      + ~~~~~~~~~~~~~~~~~~~~~~
      {{ + CategoryInfo : ObjectNotFound: (execute-andwriteoutput:String) [], CommandNotFoundException}}
      {{ + FullyQualifiedErrorId : CommandNotFoundException}}

       

            Assignee:
            Unassigned
            Reporter:
            Michael Caley
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: