Feedback

Chat Icon

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Requirements and Setup
17%

The GitLab Repository

Obviously, you need a GitLab account to follow this guide. Create a new account or log in to your existing account. After logging in, create a new group to store your projects and a new project. You can use learning as the name of the group and todo as the name of the project. We are not going to use or add any specific settings, templates, README file or licenses for this project, just an empty repository. So start a project from scratch and disable any additional settings.

After creating the project, GitLab will generate a URL for it. For example:

https://gitlab.com/learning9042634/todo

Where learning9042634 is your group name and todo is your project name. Let's export both as environment variables since we will use them later:

cat << EOF >> $HOME/.bashrc
export GITLAB_GROUP="learning9042634"
export GITLAB_PROJECT="todo"
EOF
# Source the .bashrc file to apply the changes
source $HOME/.bashrc

Add a ".git" at the end of the URL to get the Git URL and export it as an environment variable. Example:

cat << EOF >> $HOME/.bashrc
export GITLAB_URL="https://gitlab.com/$GITLAB_GROUP/$GITLAB_PROJECT.git"
EOF
# Source the .bashrc file to apply the changes
source $HOME/.bashrc

Other variables you need to export are the username and email you used to create the GitLab account:

cat << EOF >> $HOME/.bashrc
export GITLAB_USERNAME=""
export GITLAB_EMAIL=""
EOF
# Source the .bashrc file to apply the changes
source $HOME/.bashrc

Make sure to change and to your actual GitLab username and email.

Let's push the code to the GitLab repository. First, install Git:

apt update; apt install -y git

Initialize a new Git repository in the todo application directory:

cd $HOME/todo/app
git init --initial-branch=main

Add the global Git configuration:

git config --global user.name "$GITLAB_USERNAME"
git config --global user.email "$GITLAB_EMAIL"

Cloud Native CI/CD with GitLab

From Commit to Production Ready

Enroll now to unlock all content and receive all future updates for free.