jenkinsci / jenkinsci/workflow-durable-task-step-plugin

[JENKINS-41998] 'bat' step fails if configured agent overrides system path

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

Description

I started to convert a Freestyle job to a declarative Pipeline job today, and found that most of the time it was failing with the following error: 'cmd' is not recognized as an internal or external command, operable program or batch file.

After some investigation I realized that several of my build agents have the PATH variable overridden in the node configuration, i.e.

PATH=${PATH};c:\some\additional\path

With a Freestyle job,

${PATH}

is expanded correctly, but with the Pipeline job it appears not to be; adding an echo env.PATH prior to my bat step echoes an unexpanded path. It doesn't look like there's another way to get at the run environment like w/ a freestyle job, so I am not sure how else to check for sure that this is what is happening, but it seems likely.

I see the same behavior if I try PATH=%PATH%;.., which doesn't work on Freestyle jobs either, so I know that's not the problem..

If we clear the PATH override in the build agent node properties, it works fine. We're looking at whether we really need to do this override on all our build agents, but this should work just like it does with a freestyle job.

---
Originally reported by wsaxon, imported from: 'bat' step fails if configured agent overrides system path


  • status: Open
  • priority: Minor
  • component(s): workflow-durable-task-step-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 20251212-090250

Raw content of original issue

I started to convert a Freestyle job to a declarative Pipeline job today, and found that most of the time it was failing with the following error: 'cmd' is not recognized as an internal or external command, operable program or batch file.

After some investigation I realized that several of my build agents have the PATH variable overridden in the node configuration, i.e.


PATH=${PATH};c:\some\additional\path


With a Freestyle job,


${PATH}


is expanded correctly, but with the Pipeline job it appears not to be; adding an echo env.PATH prior to my bat step echoes an unexpanded path. It doesn't look like there's another way to get at the run environment like w/ a freestyle job, so I am not sure how else to check for sure that this is what is happening, but it seems likely.

I see the same behavior if I try PATH=%PATH%;.., which doesn't work on Freestyle jobs either, so I know that's not the problem..

If we clear the PATH override in the build agent node properties, it works fine. We're looking at whether we really need to do this override on all our build agents, but this should work just like it does with a freestyle job.

  • environment: Windows build agent using DCOM method, Java 1.7/1.8, Jenkins 2.32.3

3 attachments

- [nodeproperties.PNG](https://issues.jenkins.io/secure/attachment/35936/nodeproperties.PNG)
> ![nodeproperties.PNG](https://issues.jenkins.io/secure/attachment/35936/nodeproperties.PNG)
- [result.PNG](https://issues.jenkins.io/secure/attachment/35938/result.PNG)
> ![result.PNG](https://issues.jenkins.io/secure/attachment/35938/result.PNG)
- [snippet.PNG](https://issues.jenkins.io/secure/attachment/35937/snippet.PNG)
> ![snippet.PNG](https://issues.jenkins.io/secure/attachment/35937/snippet.PNG)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue on a Windows build agent with a node PATH override, comparing the Pipeline bat step with a Freestyle job. Trace how the configured PATH is expanded before bat runs; done means cmd is found and PATH behaves as it does for Freestyle jobs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.