question
1. Jenkins pulls the github code, and the console reports an error
First try to use jenkins to manually build and pull the github code, but the pull fails. Check the jenkins console for an error:
View project configuration - source code management - branch in git - the default pull is the master branch
And the github code branch is main, I didn’t change it at first, the default is master, I can’t find the branch, so I can’t pull it, change the branch to **, which means any branch, or change it to the corresponding branch of the github project, the build is successful
2. There are new submissions on github, but the jenkins build is not triggered
01. Not mapping the jenkins port to the public URL
When setting up webhook, an error is reported
Because my jenkins is built locally, and github cannot use localhost to trigger webhooks, it is necessary to map the port used by the local jenkins to the public network. The ngrok tool is used here. Download address
After downloading, run ngrok.exe directly to map the local jenkins port: ngork http (端口号)
the validity period is 2 hours, if it expires, you need to update the webhook on github
Fill in the corresponding address in the github webhook
02. Network reasons
Because I don’t have a VPN locally, so github is good and bad, sometimes pycharm can push, sometimes not, so sometimes jenkins can’t build automatically