jenkinsci / jenkinsci/credentials-binding-plugin

[JENKINS-52415] Secret File path not relative to workspace - noticeable when master is Windows, slave is Unix

Open
#458 0 comments 0 reactions 0 assignees View on GitHub
component:credentials-binding-plugin imported-jira-issue priority:blocker resolution:unresolved
Dominant language
Java
Stars
57
Forks
108
PR merge metrics
No merged PRs in 30d

Description

When the Jenkins master is running Windows and the slave is running Unix the path to the secret file is not valid.

I'm using the plugin to centrally define a Maven settings.xml file. I then reference that variable in the Maven build step.

The file is correctly copied to the slave, but the path as resolved, and then passed to the -s parameter of the mvn invocation, has had its / characters replaced with \.

This appears to be due to the path being an absolute path, which jenkins.mvn.FilePathSettingsProvider uses to create a hudson.FilePath by constructing a java.io.File object. This is where the / become \ since this is executed on the Windows master.

 

If the path generated by this plugin were relative rather than absolute the jenkins.mvn.FilePathSettingsProvider class looks like it will use string manipulation, without involving the master node's local filesystem code.

 

I've attached screenshots of the configuration.

The result when building looks like:

Started by user Robert Smith

Building remotely on slave (UNIX) in workspace /jenkins_home/workspace/my-project

Cleaning up /jenkins_home/workspace/my-project/.

Updating http://source-control/svn/my-project/trunk at revision '2018-07-06T15:30:04.873 +0100' --quiet

Using sole credentials User/****** (Subversion) in realm ‘<http://source-control:80> Subversion’

At revision 151646No changes for http:/source-control/svn/my-project/trunk since the previous build

[my-project] $ /jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Apache_Maven_3.0.4/bin/mvn -s \jenkins_home\workspace\my-project@​tmp\secretFiles\4c02e1f9-73a8-4c85-91bd-dbaa20c7e30b\settings.xml deploy

[ERROR] Error executing Maven.

[ERROR] The specified user settings file does not exist: /jenkins_home/workspace/my-project/\jenkins_home\workspace\my-project@​tmp\secretFiles\4c02e1f9-73a8-4c85-91bd-dbaa20c7e30b\settings.xml

Build step 'Invoke top-level Maven targets' marked build as failure

Finished: FAILURE

---
Originally reported by whittlec, imported from: Secret File path not relative to workspace - noticeable when master is Windows, slave is Unix


  • status: Open
  • priority: Blocker
  • component(s): credentials-binding-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251211-141027

Raw content of original issue

When the Jenkins master is running Windows and the slave is running Unix the path to the secret file is not valid.

I'm using the plugin to centrally define a Maven settings.xml file. I then reference that variable in the Maven build step.

The file is correctly copied to the slave, but the path as resolved, and then passed to the -s parameter of the mvn invocation, has had its / characters replaced with \.

This appears to be due to the path being an absolute path, which jenkins.mvn.FilePathSettingsProvider uses to create a hudson.FilePath by constructing a java.io.File object. This is where the / become \ since this is executed on the Windows master.

 

If the path generated by this plugin were relative rather than absolute the jenkins.mvn.FilePathSettingsProvider class looks like it will use string manipulation, without involving the master node's local filesystem code.

 

I've attached screenshots of the configuration.

The result when building looks like:

Started by user Robert Smith
Building remotely on slave (UNIX) in workspace /jenkins_home/workspace/my-project
Cleaning up /jenkins_home/workspace/my-project/.
Updating http://source-control/svn/my-project/trunk at revision '2018-07-06T15:30:04.873 +0100' --quiet
Using sole credentials User/****** (Subversion) in realm ‘<http://source-control:80> Subversion’
At revision 151646No changes for http:/source-control/svn/my-project/trunk since the previous build
[my-project] $ /jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Apache_Maven_3.0.4/bin/mvn -s \jenkins_home\workspace\my-project@tmp\secretFiles\4c02e1f9-73a8-4c85-91bd-dbaa20c7e30b\settings.xml deploy
[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /jenkins_home/workspace/my-project/\jenkins_home\workspace\my-project@tmp\secretFiles\4c02e1f9-73a8-4c85-91bd-dbaa20c7e30b\settings.xml
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

environment

```
Jenkins 2.121.1

Credentials Binding Plugin 1.16
```

1 attachment

- [config.png](https://issues.jenkins.io/secure/attachment/43342/config.png)
> ![config.png](https://issues.jenkins.io/secure/attachment/43342/config.png)

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.