Jenkins: what is the correct format for private key in Credentials

前端 未结 6 1842
难免孤独
难免孤独 2020-11-22 07:16

I\'m creating a job in Jenkins 2.152 running on Windows Server 2016 which needs to pull from a git repo hosted on bitbucket.org. I tested the ssh key through git-bash so I k

6条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 07:46

    In the end, I couldn't find a way to make pasting private keys to Jenkins credentials work.

    While it might common knowledge for many, I decided to put the workaround below anyway.

    Here is what I did as a workaround to pull my private repositories from Bitbucket.org:

    1. Log in to your Windows host as the user which runs Jenkins Service. In my case, Jenkins Service runs as a dedicated user because I needed to access network shares with write privileges restricted to this user only.
    2. Open Git-bash and generate SSH keys with ssh-keygen command accepting all defaults
    3. In Jenkins, enter the git repo URL as git@bitbucket.org:team_name/repo_name and leave the credentials as None

    This way Git and SSH will be able to find SSH keys in the default location, which usually is c:\Users\username.ssh\

    Hope this helps somebody.

提交回复
热议问题