jenkinsci / jenkinsci/git-plugin

add analog gitUsernamePassword for ssh

Open
#3,995 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

### What feature do you want to see added?

please add analog `gitUsernamePassword`(for example `gitSSHUsernameWithPrivateKey`) for ssh, thanks!

now if i want use `git push` i wrote
```groovy
withCredentials([gitUsernamePassword(credentialsId: 'jenkins-gitlab', gitToolName: 'Default')]) {
sh "git push origin HEAD:${env.BRANCH_NAME}"
}
```
but if repo cloned by ssh it's don't work
```
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```
we have `Git Host Key Verification Configuration` with `Manually provided keys` but it's don't work, seems need something like `gitSSHUsernameWithPrivateKey` for it

### Upstream changes

_No response_

### Are you interested in contributing this feature?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing gitUsernamePassword and gitSSHUsernameWithPrivateKey credential usage described in the issue, then trace how SSH-cloned repositories are handled. Done means an analogous SSH credential option supports git push and works with the configured Git Host Key Verification Configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java
Domain
devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.