jenkinsci / jenkinsci/credentials-plugin

[JENKINS-52179] Wrong data mapping on serialization

Open
#812 2 comments 0 reactions 0 assignees View on GitHub
component:credentials-plugin component:ssh-credentials-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
134
Forks
258
Avg merge
48m
Merged PRs (30d)
1

Description

FileOnMasterPrivateKeySource is serialized as DirectEntryPrivateKeySource.

To reproduce it:



  1. Create new credentials of type "SSH Username with private key"

  2. Fill fields with test data

  3. Select "From a file on Jenkins master" for "Private Key" and fill the field with something ("/tmp/my-cert" or the like).

  4. Save

Now read the credential from CLI:

```
java -jar jenkins-cli.jar -noKeyAuth -s http://localhost:8080/jenkins/ get-credentials-as-xml system::system::jenkins _ [your-credentials-id]

```

Output is:

```

GLOBAL
58ec63b5-92ab-4521-83b8-701fb7bd8162
test
test





```

Note the privateKeySource is com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource instead of com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource

 

I've checked serialization on disk is correct.

---
Originally reported by amuniz, imported from: Wrong data mapping on serialization


  • status: Open
  • priority: Minor
  • component(s): credentials-plugin, ssh-credentials-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 2025-12-08

Raw content of original issue

FileOnMasterPrivateKeySource is serialized as DirectEntryPrivateKeySource.

To reproduce it:



  1. Create new credentials of type "SSH Username with private key"

  2. Fill fields with test data

  3. Select "From a file on Jenkins master" for "Private Key" and fill the field with something ("/tmp/my-cert" or the like).

  4. Save

Now read the credential from CLI:



java -jar jenkins-cli.jar -noKeyAuth -s http://localhost:8080/jenkins/ get-credentials-as-xml system::system::jenkins _ [your-credentials-id]



Output is:



<com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey plugin="ssh-credentials@1.10">

<scope>GLOBAL</scope>
<id>58ec63b5-92ab-4521-83b8-701fb7bd8162</id>
<description>test</description>
<username>test</username>
<passphrase>
<secret-redacted/>
</passphrase>
<privateKeySource class="com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource">
<privateKey></privateKey>
</privateKeySource>
</com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey>


Note the privateKeySource is com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource instead of com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource

 

I've checked serialization on disk is correct.

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.