[CICD] JENKINS - fourslickz/notes GitHub Wiki

1. Generate SSH Key DI SERVER JENKINS

Jika Jenkins container

docker exec -it jenkins bash

Generate key

ssh-keygen -t ed25519 -C "jenkins@github" -f /var/jenkins_home/.ssh/id_ed25519

2. Register SSH key PUBLIC ke Github

setup keys

  • GitHub → Settings → SSH and GPG keys
  • Add new SSH key
cat /var/jenkins_home/.ssh/id_ed25519.pub

validate key

ssh -T [email protected]

Tambahkan SSH Key PRIVATE ke Jenkins Credentials

Manage Jenkins → Credentials → Global → Add Credentials

  • Kind: SSH Username with private key
  • Username: git
  • Private Key: Enter directly
  • Paste isi file:
cat /var/jenkins_home/.ssh/id_ed25519
  • ID: github-ssh
  • Description: GitHub SSH Jenkins

3. Webhook

setup GitHub Webhook → Jenkins

  • Di GitHub Repo
  • Settings → Webhooks → Add webhook
  • Payload URL
https://jenkins.domainkamu.com/github-webhook/

4. Tambahkan plugin ssh agent pada jenkins

Manage Jenkins

  • Plugins
  • Available plugins
  • Cari: SSH Agent