1, Introduction to GitLab Runner
GitLab Runner is an open source project that runs your job and sends the results back to GitLab. It works with GitLab CI, an open source continuous integration service that comes with GitLab to coordinate jobs.
GitLab Runner is written in Go and can be run as a single binary file without language specific requirements.
2, Three types of GitLab Runner
shared: job that runs the entire platform project (gitlab)
Group: a job (group) that runs all items under a specific group
specific: run the specified project job (project)
3, GitLab Runner has two statuses
locked: unable to run project job
paused: the job will not run
4, GitLab Runner installation
Since the services are now on the container, only the method of installing GitLab Runner with docker is demonstrated here. For other methods, please refer to the official website.
Official website address: https://docs.gitlab.com/runner/install/
$ mkdir -p /data/gitlab-runner/config $ docker run -itd --restart=always --name gitlab-runner \ -v /data/gitlab-runner/config:/etc/gitlab-runner \ -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest $ docker exec -it gitlab-runner bash root@24dc60abee0b:/# gitlab-runner -v Version: 13.8.0 Git revision: 775dd39d Git branch: 13-8-stable GO version: go1.13.8 Built: 2021-01-20T13:32:47+0000 OS/Arch: linux/amd64
5, GitLab Runner registration
Note: the premise of registering gitlab runner is that there must be a usable gitlab repository
Click user management – click runner on the left to see the gitlab address and token on the right of the interface. This needs to be used for the registration of runner later. Here we register a runner of type share.
Since the runner is installed with docker, you need to enter the runner container for registration
[root@localhost config]# docker exec -it gitlab-runner bash root@24dc60abee0b:/# gitlab-runner register Runtime platform arch=amd64 os=linux pid=86 revision=775dd39d version=13.8.0 Running in system-mode. Enter the GitLab instance URL (for example, https://gitlab.com/): http://192.168.50.128/ Enter the registration token: iqxKz5XTz4w_2RxiSQ5S Enter a description for the runner: [24dc60abee0b]: node1.ayunw.cn Enter tags for the runner (comma-separated): default Registering runner... succeeded runner=iqxKz5XT Enter an executor: docker-ssh+machine, kubernetes, custom, shell, ssh, virtualbox, docker, docker-ssh, parallels, docker+machine: docker Enter the default Docker image (for example, ruby:2.6): docker:19.03.15 Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! root@24dc60abee0b:/# gitlab-runner restart Runtime platform arch=amd64 os=linux pid=98 revision=775dd39d version=13.8.0 Terminated root@24dc60abee0b:/# gitlab-runner list Runtime platform arch=amd64 os=linux pid=130 revision=775dd39d version=13.8.0 Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml node1.ayunw.cn Executor=docker Token=VSVWeipeMirJsJo9znT5 URL=http://192.168.50.128/
After the runner registration is completed, a config.config file will be generated in the / etc / gitlab runner directory Toml files. This is the runner configuration file. When installing runner, we have mapped the directory of the configuration file to the host Directory: / data / gitlab runner / config in the form of mount, so if you need to update the runner configuration file later, you can modify it directly on the host. Moreover, it is not necessary to restart the runner to modify the runner configuration file on the host. It checks the file every 5 minutes and automatically gets all changes. Include any parameters defined in the [[runners]] section and most parameters (except listen) in the global section_ address.
The configuration is as follows:
root@24dc60abee0b:/etc/gitlab-runner# cat config.toml concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "node1.ayunw.cn" url = "Yours gitlab Visited url address" token = "stay gitlab of ui I saw it on the token" executor = "docker" [runners.custom_build_dir] [runners.cache] [runners.cache.s3] [runners.cache.gcs] [runners.cache.azure] [runners.docker] tls_verify = false image = "docker:19.03.15" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0
After registration, return to the ui of gitlab to view the registered runner.
You can see that the current runner is locked. If you need to use this runner, you need to unlock it. We can click edit on the right and uncheck "lock to current project". Then check to run unmarked jobs. Now the runner is ready to run.
6, Test pipeline
Create a new project, and then submit one in the project root directory gitlab-ci.yml file, as follows. When submitted, the pipeline pipeline will be triggered.
stages: - maven - build - deploy maven_job: stage: maven tags: - default only: - master script: - echo "This is the first maven job" build_job: stage: build tags: - default only: - master script: - echo "This is the first build job" deploy_job: stage: deploy tags: - default only: - master script: - echo "This is the first deploy job"
So far, gitlab runner has been installed and the whole pipeline can run normally.
Official account: operation and development story
github: https://github.com/orgs/sunsharing-note/dashboard
Love life, love operation and maintenance
If you think the article is good, please click on the top right corner to send it to your friends or forward it to your circle of friends. Your support and encouragement is my greatest motivation. If you like, please pay attention to me~
Scanning QR code
Pay attention to me and maintain high-quality content from time to time
reminder
If you like this article, please share it with your circle of friends. For more information, please follow me.
........................