jenkinsci / jenkinsci/credentials-binding-plugin

[JENKINS-59737] sshUserPrivateKey's "KeyFileVariable" is missing drive letter on windows

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

Description

I am seeing a bug when using 

withCredentials([sshUserPrivateKey(credentialsId: 'myCred', keyFileVariable: 'privateSshKey')]){}

 

Documentation for keyFileVariable states that it is "an environment variable to be set to the temporary path of the SSH key file".

 

The problem is that the value of the variable is a nearly, but not quite, absolute path.  On Windows specifically, it is missing the drive letter and colon.  This causes it to fail with commands such as "ssh -i ${privateSshKey} myUrl".

 

Example:  If the actual path is

`C:\home\jenkins\agent\workspace\myjob@​abc\def\ghi-privateSshKey`,

then the environment variable is incorrectly set to

`/home/jenkins/agent/workspace/myjob@​abc/def/ghi-privateSshKey`

 

This was very difficult to debug because the plugin masks/censors all output containing the path.  There should be a way to opt out of the masking of logs.

 

 

---
Originally reported by cowlinator, imported from: sshUserPrivateKey's "KeyFileVariable" is missing drive letter on windows


  • status: Open
  • priority: Major
  • component(s): credentials-binding-plugin
  • label(s): Credentials, credentials, plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 20251211-141027

Raw content of original issue

I am seeing a bug when using 

withCredentials([sshUserPrivateKey(credentialsId: 'myCred', keyFileVariable: 'privateSshKey')]){}

 

Documentation for keyFileVariable states that it is "an environment variable to be set to the temporary path of the SSH key file".

 

The problem is that the value of the variable is a nearly, but not quite, absolute path.  On Windows specifically, it is missing the drive letter and colon.  This causes it to fail with commands such as "ssh -i ${privateSshKey} myUrl".

 

Example:  If the actual path is

`C:\home\jenkins\agent\workspace\myjob@abc\def\ghi-privateSshKey`,

then the environment variable is incorrectly set to

`/home/jenkins/agent/workspace/myjob@abc/def/ghi-privateSshKey`

 

This was very difficult to debug because the plugin masks/censors all output containing the path.  There should be a way to opt out of the masking of logs.

 

 

environment

```
Master:

    Jenkins v 2.176.1

    from docker image jenkins/jenkins:lts

    Credential binding plugin v 1.19

Node:

    Windows Server 2019 (amd64)
```

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.