jenkinsci / jenkinsci/durable-task-plugin

[JENKINS-54618] Pipeline powershell step hangs if a function is called from powershell workflow

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

Description

I have a Jenkins pipeline that contains a step 'powershell'. From the powershell script, I want to execute some actions in parallel. powershell has the Workflow concept for this (not to confuse with Jenkins workflow).

If I execute the script from the powershell console, everything works OK. If I execute the same script from within a Jenkins pipeline, it hangs. The only output I see is:

[Pipeline] {

[Pipeline] stage
[Pipeline] { (test)
[Pipeline] powershell

 

The Jenkins pipeline script is as follows (it contains some commented lines to make changes easy, see below):

node('myNode') {

stage('test') {
powershell '''
function execFunc($n) {
Write-Output "I am $n"
}

Workflow execInParallel() {
foreach -parallel ($n in 1,2) {
execFunc $n
#Write-Output "I am $n" # Change 1
}
}

function execSequentially() {
foreach ($n in 1,2) {
execFunc $n
}
}

execInParallel
#execSequentially # Change 2
'''
}
}


The script as it is hangs.

However, if I make the following changes (independently, i.e. each change on its own is sufficient), it does not hang:



  1. If I "inline" the function execFunc, i.e. activate the line 'Change 1' and comment the line above (the call to execFunc), the script does not hang

  2. If I replace the parallel execution with the sequential one, i.e. activate the line 'Change 2' and comment the line above (call to 'execInParallel'), then the script does not hang.

The hanging only occurs if I use the powershell workflow and call a function from within it.

In an earlier version of the "Pipeline: Nodes and Processes" plugin (I think, it was 2.17, but I'm not sure), everything worked OK.

The job itself is named "zzzTestPowershellWorkflow" I.e. the name does not contain any "bad" characters (spaces or the like).

---
Originally reported by fml2, imported from: Pipeline powershell step hangs if a function is called from powershell workflow


  • status: Open
  • priority: Minor
  • component(s): durable-task-plugin
  • label(s): pipeline, powershell
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-09

Raw content of original issue

I have a Jenkins pipeline that contains a step 'powershell'. From the powershell script, I want to execute some actions in parallel. powershell has the Workflow concept for this (not to confuse with Jenkins workflow).

If I execute the script from the powershell console, everything works OK. If I execute the same script from within a Jenkins pipeline, it hangs. The only output I see is:



[Pipeline] {

[Pipeline] stage
[Pipeline] { (test)
[Pipeline] powershell


 

The Jenkins pipeline script is as follows (it contains some commented lines to make changes easy, see below):



node('myNode') {

stage('test') {
powershell '''
function execFunc($n) {
Write-Output "I am $n"
}

Workflow execInParallel() {
foreach -parallel ($n in 1,2) {
execFunc $n
#Write-Output "I am $n" # Change 1
}
}

function execSequentially() {
foreach ($n in 1,2) {
execFunc $n
}
}

execInParallel
#execSequentially # Change 2
'''
}
}


The script as it is hangs.

However, if I make the following changes (independently, i.e. each change on its own is sufficient), it does not hang:



  1. If I "inline" the function execFunc, i.e. activate the line 'Change 1' and comment the line above (the call to execFunc), the script does not hang

  2. If I replace the parallel execution with the sequential one, i.e. activate the line 'Change 2' and comment the line above (call to 'execInParallel'), then the script does not hang.

The hanging only occurs if I use the powershell workflow and call a function from within it.

In an earlier version of the "Pipeline: Nodes and Processes" plugin (I think, it was 2.17, but I'm not sure), everything worked OK.

The job itself is named "zzzTestPowershellWorkflow" I.e. the name does not contain any "bad" characters (spaces or the like).

  • environment: Windows Server 2012 R2 64 Bit, Jenkins 2.138.2, Pipeline: Nodes and Processes 2.26, Durable Task Plugin 1.27

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.