Я вытягиваю общедоступное репозиторий git и пытаюсь использовать учетные данные denpal (закрытый ключ SSH), чтобы перенести мои изменения обратно в репозиторий.
stages {
stage('Git clone') {
steps {
git branch: 'feature/Jenkinsfile',
credentialsId: 'denpal',
url: 'git@github.com:test/denpal.git'
}
}
stage('Test Git') {
steps {
withCredentials([sshUserPrivateKey(credentialsId: 'denpal', keyFileVariable: 'SSH_KEY')]) {
sh '''
git commit --allow-empty -m "test withCredentials"
git push origin feature/Jenkinsfile
'''
}
}
}
К сожалению, это приводит к следующей ошибке:
> git --version # timeout=10
using GIT_SSH to set credentials denpal
> git fetch --tags --force --progress git@github.com:test/denpal.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/feature/Jenkinsfile^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/feature/Jenkinsfile^{commit} # timeout=10
Checking out Revision ... (refs/remotes/origin/feature/Jenkinsfile)
> git config core.sparsecheckout # timeout=10
> git checkout -f ...
> git branch -a -v --no-abbrev # timeout=10
> git branch -D feature/Jenkinsfile # timeout=10
> git checkout -b feature/Jenkinsfile ...
Commit message: "empty"
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test Git)
[Pipeline] withCredentials
Masking only exact matches of $SSH_KEY
[Pipeline] {
[Pipeline] sh
+ git commit --allow-empty -m test withCredentials
[feature/Jenkinsfile 3ff21fc] test withCredentials
+ git push origin feature/Jenkinsfile
ERROR: Permission to test/denpal.git denied to technology-labs.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[Pipeline] }
[Pipeline] // withCredentials
Я тоже пробовал это, но это тоже не удалось:
withCredentials([sshUserPrivateKey(credentialsId: 'denpal', keyFileVariable: 'private_key', passphraseVariable: '', usernameVariable: 'git')]){
Есть идеи, что я делаю не так?