I’m having a problem with running a Jenkins Pipeline script from SCM. Jenkins doesn’t clone the code from my private Github repository to Jenkins’ private workspace (Console output). I have a private repository on Github, from which I get the code that the pipeline has to execute. On the virtual machine on which Jenkins is installed I’ve executed the following commands to generate a SSH-keypair:
sudo su jenkins ssh-keygen
I’ve added the public key to my Github repository under “Deploy keys” and the private key in Jenkins under Manage Jenkins → Manage Credentials → Global credentials → Add Credentials as SSH Username with private key (with “jenkins” as Username). This worked for about a week. Last monday (30/05/2022) it suddenly stopped cloning the code from my private Github repository into the local workspace of the vm, which is /var/lib/jenkins/workspace/“pipeline name”. After that I’ve tried the following:
- Revert a snapshot of the VM that was made after the installation of Ubuntu server 20.04.4 and install Java 11 and Jenkins freshly
- Remove my Github account and make a new one
- Make a new repository
- Generate new SSH-keypairs
- Use HTTPS and a Github personal access token
After this I tried to generate a new ssh-keypair using this command:
ssh-keygen -t rsa -b 4096 -C "my_email"
I’ve added the public key to my Github profile under “SSH and GPG keys” and the private key in Jenkins under Manage Jenkins → Manage Credentials → Global credentials → Add Credentials as SSH Username with private key (with my email adress of my Github profile as Username).
When I navigate to /var/lib/jenkins/workspace/“pipeline name”, a Git Clone <-SSH url-> does work and my pipeline runs without failing. However, this manual action is not preferred.