For you who are using Nestj as a project for the first time (Part 2: Configure gitlab-runner & operate gitlab)
If you don’t want to build gitlab
, please skip to section 6.
1. CI/CD
We usually use some CI/CD
continuous integration, for example, the dev
gitlab
is updated every time, but these functions are not CI
, we will directly package and publish to the test environment, then we will configure This functional module.
2. gitlab-runner
Performing construction tasks is very performance consuming, so gitlab
uses gitlab-runner
alone to build projects independently, so in fact, gitlab
provides an interface that can correspond to multiple runner
, and different projects can be built with different runner
.
Step 1: pull
docker pull gitlab/gitlab-runner
Step 2: run
docker run -d --name gitlab-runner --restart always \
-v ~/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner
The above is a mapping of the configuration docker
Step 3: Registration
docker exec -it 容器id gitlab-runner register
It means I am going to execute gitlab-runner register
The container id above can be viewed with the following command
docker container ps -a
Register and fill in the information
When the registration command is executed, we will let us fill in Url
and Token
. This parameter can be found in the picture:
Or open a project:
- Set label
You can understand it as setting up an alias for us to manage and call this runner
.
- Setting up the environment
Here it is not equipped with node
like, do not shell
, direct selection docker
.
- Set the default mirror
3. Configure runner
Let's first look at the activated runner
.
The tag here is set during initialization just now.
Set it to default runner
4. Pull the address of the project for correction (configure gitlab)
Into our container
docker exec -it gitlab_lulu bash
vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
Now you can access it correctly:
5. Upload a yml
file to try
Just build a vue
project
image: node
cache:
paths:
- node_modules/
install:
tags:
- tag1
script:
- echo 1111
6. Initially a gitlab
module
This library is seldom used, and the documents are all in English. I will talk about how to learn it later.
installation
yarn add @gitbeaker/node
Generate gitlab
module
nest g controller modules/gitlab
nest g service modules/gitlab
Simple configuration
/share/src/modules/gitlab/gitlab.controller.ts
import { Controller, Get } from '@nestjs/common';
import { GitlabService } from './gitlab.service';
@Controller('gitlab')
export class GitlabController {
constructor(
private readonly gitlabService: GitlabService
) { }
@Get()
getTags() {
return this.gitlabService.getTags();
}
}
/share/src/modules/gitlab/gitlab.service.ts
import { Injectable } from '@nestjs/common';
@Injectable()
export class GitlabService {
getTags() {
return 'tags列表'
}
}
The effect is as follows:
Seven. Use @gitbeaker/node
operate gitlab
: Get all tag
/share/src/modules/gitlab/gitlab.service.ts
The first step is to get token
token
with 0609c650077174 can you have the right to access some items, turn on the permissions, and set the expiration time.
Copy your token and put it in the project.
The second step is new
an api instance
The third step is to label and try
8. How to learn to use @gitbeaker/node
The first step: query the desired api
Search for the keywords you want here, api document
Step 2: Click in to find the operation you want
For example, this new label
Step 3: Generally, the operation name is the method name
Check his parameter settings, options
is generally the parameters to be passed.
Step 4: call the method
This ref can be understood as a unique label, so it can be commitID
:
Step 5: View the results
end.
Next, we are going to perform database-related operations. If you have not done back-end related projects, you should take a closer look. It involves how typeorm handles many-to-many and many-to-one relationships. I will compare the pits I encountered I will show you all the experience and experience, and I hope to make progress with you.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。