Jenkins¶
Install Jenkins locally¶
mkdir jenkins
cd jenkins
docker run --name jenkins \
-u root \
-d \
-v $(pwd):/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-p 80:8080 \
-p 50000:50000 \
jenkinsci/blueocean
Then open http://127.0.0.1:80 and follow the directions
Integrate with github private repo¶
Do other steps same as the public repo.
setup ssh key¶
docker exec -it jenkins /bin/bashssh-keygen -t rsacat id_rsa.pubcopy key to github: repo settings -> Deploy keys -> Add deploy key- add ssh private key inside Jenkins:
- manage jenkins -> manage credentials ->
- Kind: ssh username with private key ->
- Username: github-repo
- configure jenkins job to use SSH keys:
- job -> source code management
- after repo url -> select credential (github-repo) -> apply
use the SSH repo URL, not the HTTPS URL on jenkins¶
- HTTPS URL like https://github.com/user/repo.git
- SSH URL like git@github.com:user/repo.git
errors¶
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Solution: job configuration -> Source Code Management -> Git -> Branches to build -> it is default to "/master" -> change to "/main" github repo project is under "main" branch