jenkinsci / jenkinsci/durable-task-plugin

[JENKINS-48415] Pipeline PowerShell won't execute when there's spaces in the path

Open
#411 3 comments 0 reactions 0 assignees View on GitHub
component:durable-task-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
30
Forks
101
PR merge metrics
No merged PRs in 30d

Description

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

 

---
Originally reported by mcaley, imported from: Pipeline PowerShell won't execute when there's spaces in the path


  • status: Open
  • priority: Minor
  • component(s): durable-task-plugin
  • label(s): triaged-2018-11, windows
  • resolution: Unresolved
  • votes: 1
  • watchers: 5
  • imported: 2025-12-09

Raw content of original issue

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

 

environment

```
Jenkins 2.73.3 on Windows Server 2012 R2

Jenkins 2.93 on Windows 10 Enterprise
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.