Home | About | Blog | Skills | Innovations | Work with Me | Connect with me | Other Links
Published On: Jun 05 2025
Written By: Krishnan Sethuraman
Category: Server Mechanic
I woke up last Monday fully charged up to start the tasks that I had planned for the week. That is when I got a call from one of my team members complaining that they were not able to commit the code to our Bitbucket repository.
I logged in to figure out what was wrong and a yellow bar flashed in on the screen saying that we had exhausted the one GB storage space that comes with every free Bitbucket account. For a second I thought that upgrading would be the best option but then the new found technical writer in me suggested that I should set up Gitlab on Linux box and migrate all our repositories once and for all and then write a self loathing blog article on the topic.
In this article/guide, I’ll walk through setting up Gitea, a lightweight and fast self-hosted Git service, and integrating it with Jenkins to automatically trigger builds when code is pushed or a pull request is merged to the master branch.
Before we move any further let us understand why I decided to go with Gitea instead of Gitlab. Gitlab was my first choice but after some research it was evident to me that Gitea served my purpose best.
We wanted a simple and easy to use source code repository. We already had a stable Jenkins setup to manage our CI/CD activities and were not looking for the same features in our repository. So from the context Gitea was the right choice for us. Additionally Gitlab demanded more RAM but Gitea was lightweight and could easily be run on a $5/month server.
Gitea also had a Github-like web interface which made it easy for the entire team to adopt in a few hours. Also this was our own source code management system and there was no limitation in terms of users or size.
Setting up Gitea is pretty straightforward.
The prerequisites are simple and straightforward.
Create the DNS record for the domain that you have chosen. Keep the TTL as low as possible. You will need it later.
$ sudo su
# adduser \
--system \
--shell /bin/bash \
--group \
--disabled-password \
--home /home/git git
# wget -O gitea https://dl.gitea.io/gitea/1.21.11/gitea-1.21.11-linux-amd64
# chmod +x gitea
# mv gitea /usr/local/bin/gitea
# mkdir -p /home/git/gitea/{custom,data,log}
# chown -R git:git /home/git/gitea
To ensure Gitea runs automatically you need to create a systemd service.
Create the file /etc/systemd/system/gitea.service
Copy and paste the content in the file.
[Unit]
Description=Gitea
After=network.target
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea
ExecStart=/usr/local/bin/gitea web --config /home/git/gitea/custom/conf/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/home/git/gitea
[Install]
WantedBy=multi-user.target
Start the new Gitea service
# systemctl daemon-reload
# systemctl enable --now gitea
You can check the status of Gitea
# systemctl status gitea
At this point you should be able to open Gitea on the browser at http://<gitea server IP>:3000.
Install apache on your Gitea server.
# apt install apache2
After Apache is installed, create a virtual host for the chosen domain. In our case it is gitea.domain.com.
Ensure that gitea.domain.com works in https and not http. You can use Letsencrypt for this purpose.
As this is a private repository I disabled user registration.
Edit /home/git/gitea/custom/conf/app.ini:
[service]
DISABLE_REGISTRATION = true
Then restart:
# systemctl restart gitea
Make sure the git user has a shell:
# chsh -s /bin/bash git
Add your SSH public key via the Gitea web UI:
Go to: https://gitea.yourdomain.com
Login → Profile → SSH Keys → Add Key
Create a new repository and check if you are able to checkout the repository locally and also commit code.
With this setup, you now have a fully self-hosted, Bitbucket-free Git Gitea. It's super easy and very similar to Github. Integrating with Jenkins to automate builds was also straightforward. Gitea has options to migrate the repositories from other source but in my case I wanted to manually migrate the repositories so that I had more control over the mgiration. Also I wanted to only migrate the repositories I needed and delete the rest.
Like what you are reading?
Discover more similar articles sent to your email
Subscribe to my newsletter