If you are coming from the Jenkins world, you may be wondering whether GitLab pipelines can accept parameters. They can and I’ll demonstrate below how to define and run parameterized pipelines in GitLab. If you later find this article useful take a look at the disclaimer for information on how to thank me.
Tag: gitlab
Go Docker CI in GitLab
Today, I’ll demo a sample Go Docker CI pipeline in GitLab. The pipeline will run on a sample Go containerized app. Hence the name Go Docker. If you later find this article useful take a look at the disclaimer for information on how to thank me.
Assume you want to clone a private GitLab repository in your GitLab pipeline. Let’s see how to do that. If you later find this article useful take a look at the disclaimer for information on how to thank me.
Why Clone Repositories in GitLab Pipelines?
You probably know why you need that. You have never done it and wonder why you may need it? For example, your GitLab pipeline may run some automation (e.g. patterns replacements, version bumps) on specific repositories. To perform the changes in the repositories, you first need to clone the repository in your pipeline, do some changes, then commit and push it. However first, you need to clone it. While cloning repositories manually is straightforward either using https or ssh url, cloning in GitLab pipelines requires a bit different url. Let’s see how it looks and a demo GitLab pipeline using it.
Clone Private Repositories in GitLab Pipelines Demo
Let’s have a look at a sample GitLab pipeline which clones another private repository. In addition, it makes a sample change, commits and pushes it. Note that cloning private repository requires authentication, while clone public does not. To authenticate you’d need to generate a personal or group access token of at least read_repository
scope. Add the token to the GitLab project or group masked variables.
Below is the pipeline which uses the variable GITLAB_TOKEN
.
stages:
- update_repo
build-job:
stage: update_repo
- git config --global user.email "[email protected]"
- git config --global user.name "Your Name"
script:
- echo "updating repo"
- git clone https://oauth2:[email protected]/[your_user]/[another_project_name].git
- cd [project_name]
- echo 'test' > test.txt
- git commit -am 'test'
- git push
- cd -
Note above that to clone the repository you need to run:
git clone https://oauth2:[email protected]/[your_user]/[another_project_name].git
where GITLAB_TOKEN
is defined as the GitLab project or group masked variable.
Summary
That’s it about using clone private repositories in GitLab pipelines. As always feel free to share. If you found this article useful, take a look at the disclaimer for information on how to thank me.
You can also find below articles useful:
- GitLab Self-Hosted Runners Demo
- Get user’s permissions using kubectl
- Migration from Jenkins to GitLab
- Git Tricks: git commit –amend + git force –push
Recommended GitLab books on Amazon.
If you developed modern CI/CD pipelines you probably stumbled on the need to auto tag releases with semantic versions. Today I’ll show how to do that automatically and which tools may help to achieve automatic tagging releases with semantic versions.
If you later find this article useful take a look at the disclaimer for information on how to thank me.
GitLab Self-Hosted Runners Demo
In this post we’ll see how and why to use GitLab self-hosted runners. As always, I’ll show a practical demo of GitLab self-hosted runner which runs jobs in CI/CD pipelines. If you later find this article useful take a look at the disclaimer for information on how to thank me.
Migration from Jenkins to GitLab
Have you considered migration from Jenkins to GitLab? While working on CI/CD pipelines in Jenkins, you probably didn’t like coding them in Groovy. You wondered if any simpler CI/CD platform exists where you just have to worry about what commands to run in the pipelines. We’ll review important things to consider while planning migration from Jenkins to GitLab.