惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

git入门系列 on 打工人日志

CI/CD 可观察性-基于grafana sonarqube docker安装和配置 SSH 通过 443 端口连接 GitHub ansible 命令 Git 规则 git版本控制 CICD 概念 git使用方法 Jenkins 安装与使用 Gitlab批量导出用户 ansible 安装和部署 gitlab与github同步项目 git技巧 Markdown教程
gitlab CI/CD 的使用
2021-12-03 · via git入门系列 on 打工人日志

gitlab CI/CD 的使用

我将使用 gitlab 的流水线自动实现 hugo blog 文章的自动发布。

一、基础知识

二、安装过程

1.安装 gitlab runner

首先需要安装 gitlab runner 进入服务器 A
安装方法:

  1. 容器部署

  2. 手动二进制文件部署

  3. 通过 rpm/deb 包部署

  4. docker 方式安装

安装文档:https://docs.gitlab.com/runne…

1    docker run -dit \
2    --name gitlab-runner \
3    --restart always \
4    -v /srv/gitlab-runner/config:/etc/gitlab-runner \
5    -v /var/run/docker.sock:/var/run/docker.sock \
6    gitlab/gitlab-runner

1.1 设置信息

docker exec -it gitlab-runner gitlab-runner register
  1. 非 docker 方式安装

2.1 安装 GitLab Runner

安装环境:Linux

其他环境参考:https://docs.gitlab.com/runne…

下载

1    curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

添加权限

1    chmod +x /usr/local/bin/gitlab-runner

新建 gitlab-runner 用户

1    sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

安装

安装时需要指定我们上面新建的用户

1    gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

启动

 1# Download the binary for your system
 2sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
 3
 4# Give it permissions to execute
 5sudo chmod +x /usr/local/bin/gitlab-runner
 6
 7# Create a GitLab CI user
 8sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
 9
10# Install and run as service
11sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
12sudo gitlab-runner start

2.配置 docker shell 链接

 1    ssh-keygen -t rsa
 2    cd .ssh/
 3    cat id_rsa.pub >>authorized_keys
 4    docker cp id_rsa gitlab-runner:/root
 5    docker exec -it gitlab-runner /bin/bash
 6    chmod 600 /root/id_rsa
 7
 8
 9    vim /etc/systemd/system/gitlab-runner.service
10
11    "--syslog" "--user" "root" #修改为root
12    wq保存退出
13
14    systemctl daemon-reload
15    systemctl restart gitlab-runner

3.配置.gitlab-ci.yml 文件

 1    vim .gitlab-ci.yml
 2
 3    stages:
 4    - build
 5    - test
 6    - deploy
 7
 8    build-job:
 9    stage: build
10    script:
11        - echo "上传代码"
12        - echo "上传完成."
13
14    unit-test-job:
15    stage: test
16    script:
17        - echo
18        - sleep 60
19        - echo "Code coverage is 90%"
20
21    lint-test-job:
22    stage: test
23    script:
24        - echo "Linting code... This will take about 10 seconds."
25        - sleep 10
26        - echo "No lint issues found."
27
28    deploy-job:
29    stage: deploy
30    script:
31        - echo "Deploying application..."
32        - echo "Application successfully deployed."