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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • durable-task-plugin
    • Jenkins 2.73.3 on Windows Server 2012 R2
      Jenkins 2.93 on Windows 10 Enterprise

      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}}

       

            Unassigned Unassigned
            mcaley Michael Caley
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: