This is the seventh day of my participation in the First Challenge 2022. For details: First Challenge 2022.
The front end
In other words, due to the lack of operation and maintenance of the company, the maintenance and release of all the environment were either done by the developer or as the author of the test. Besides, some projects consumed huge resources during construction and could not complete the construction, so the former Jenkins server of Ali Cloud could not be correctly deployed. Therefore, the author created a job in the local Jenkins server. Implement local build package upload to production server specified path, and then production Jenkins server shell script one-click deployment. However, the reality is that local Jenkins cannot be accessed from the Internet. Recently, they have been building and deploying at home for a long time. If they cannot be packaged locally due to emergency release, the author also provides CLI commands to trigger Jenkins construction. Just execute the shell script from the JumpServer jumper. But yeah, that’s still inconvenient, certainly not as convenient as accessing Jenkins’ click-trigger directly. So the author is also a bit of a rascal, how can we solve this problem?
idea
Most of the local Jenkins are built manually, and even the automated test scripts executed are done through scheduled tasks. So can this difficult project work this way? It’s not a good idea. After all, it doesn’t need to be built every time, and it’s not an iteration a week. So can you configure Github as before, and trigger it by code push of Git repository? First of all, the company uses coding as a code warehouse, instead of building a GitLab server locally. One more condition is that local Jenkins can’t access the Internet! Excuse me?
coincidence
Firstly, coding supports the setting of Webhook Jenkins mechanism in the project. In the test environment, a domain name is temporarily used with low frequency, or even abandoned.
Then configure the nginx proxy to the local Jenkins server through the test environment; So you know, if the conditions are met, just roll up your sleeves and get going.
To start
The first thing to install is Jenkins’ Coding Webhook Plugin
In job configuration — build trigger, check Coding to get the Webhook address, remember that the domain name must be accessible to the Internet
In Jenkins system administration — the Jenkins Location address configured for the system should also be the same domain name
Now go to Coding — Project — and select project Settings in the lower left
Go to the developer options, go to Service Hook, and click New Service Hook
The default is Webhook
In selecting code push, merge request, next
The service URL is the Webhook address obtained from Jenkins’ job building trigger coding
After the test is complete, click send record next to the status to see the record of the test (the free status is green, which means it was successful, but Jenkins does not build).
So you need to modify and push the code in your own project, then go to Jenkins and see how it works.
conclusion
Whoever helps them up, I finally finish the big moves, supports both local cli scripting, and support an automated build, it can be said to be the best of both worlds, the only problem is that if the domain name suddenly going to do the test, the Jenkins of the webhook address may be failure, is still not perfect, it is necessary I hope there will be more solution!