Setup Gitea/Forgejo support¶
Note
The following instructions also apply to Forgejo instances.
CodeMC supports hooking into Gitea instances for creating new builds whenever a commit is done to your project.
Setup automatic Builds¶
CodeMC allows you to create builds whenever a commit is pushed to your repository.
Unlike other Sites is the setup for Gitea/Forgejo a little more complicated and requires some steps on the CI first.
Important
Using this setup will trigger a build, no matter the changes or targeted files.
It will ignore any exclusion/inclusion settings of the Polling options.
Use the Periodic Builds setup to avoid this.
- Login to your account on
https://ci.codemc.ioif you haven't already. - Click your username on the top-right.
- Click Security on the left-hand side.
- Under API Token press Add new Token, give the token a proper name and press Generate.
- Copy the token.
- Encode the token alongside your Username in the format
{username}:{token}using a Base64 encoder (i.e. base64encode.org). - Copy the generated Base64 code for later.
After completing the above steps, head over to your Gitea/Forgejo repository and follow these steps.
- Press Settings
- Press Webhooks on the left-hand side.
- Press the Add Webhook button and select Gitea ( Forgejo may also work).
- Add
https://ci.codemc.io/job/{username}/job/{project}/buildas the target URL. - Under Trigger on either leave it at
push eventsor choseCustom events...and choose the following:Pull requestPush
- Under Authorization-Header put
Basic {code}where{code}is the Base64-encoded text you've created previously. - Press Add Webhook to save your new Webhook.
Setup periodic Builds¶
If you don't need to have builds made when a commit is pushed, periodic builds can be used instead to check your repository for changes and build those regularly.
- Login to your account on
https://ci.codemc.ioif you haven't already. - Head over to your project on CodeMC and open the settings by clicking Configure.
- Under Source Code Management make sure that Git is selected and that the URL to your repository is configured under Repository URL
- Make sure that Branch Specifier (blank for 'any') is set to the default branch of your repository (Usually
*/masteror*/main). - Optional: Under Additional Behaviours press the Add button and add Polling ignores commits in certain paths to add settings to define paths that should be included or excluded during a poll.
- Make sure that Branch Specifier (blank for 'any') is set to the default branch of your repository (Usually
- Scroll down to the Triggers section and make sure to check Poll SCM
-
In the Schedule field, add a cron-job-compatible pattern. crontab.guru can be used to create one.
Please keep the frequency of polls to a reasonable number such as every 15 minutes (H/15 * * * *). Cron jobs that make excessive calls will be removed.Tip
Hshould be used instead of*when defining a interval for the polling.Using
Htells the CI to delay the poll should too many other polls already be run at the same time, reducing load on the CI in general.
Note thatHis not a supported cron-job pattern and specific to the CI. Sites such as crontab.guru will not support it. -
Press Save to save and apply your changes.