fix: fail to create github webhook automatically #939
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Bird aflybird0@gmail.com
Description
I created a new plugin in #921 to automatically create a Jenkins Job triggered by GitHub.
This pr is here to fix it.
Although the code looks weird, in the short term, it's the easiest and quickest way to fix it.
After a lot of troubleshooting, here's why I couldn't automatically generate the webhook
The first step is to create a ConfigMap to generate JCasC, which has a setting
manageWebhooks: trueto automatically create a webhook for the GitHub repo when you create a job, and the second step is to create a Jenkins job.The problem is that after creating the ConfigMap in step 1, you need to poll the ConfigMap via sidecar to convert it to JCasC, so the
manageWebhooksconfiguration takes effect after the job is created.We just need to make sure that we create the job after the configuration takes effect. The current strategy is to sleep for 3 seconds.
Of course, the best strategy is to poll the latest JCasC and create the job as soon as the configuration takes effect, but considering that we need to spend time testing the project near the release, and that Jenkins installation itself is a very time-consuming task, it is acceptable to wait three seconds longer than that.
Related Issues
#921
New Behavior (screenshots if needed)