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

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

gitlab on 打工人日志

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

Jenkins 安装与使用

代码在本地修改—-》提交到远程 gitlab—-》触发 jenkins 整个自动化构建流程(打包,测试,发布,部署)

安装 docker

安装 docker

docker 安装 jenkins

 1docker run \
 2  -u root \
 3  -d \
 4  -p 8080:8080 \
 5  -p 50000:50000 \
 6  -v jenkins-data:/var/jenkins_home \
 7  -v /etc/localtime:/etc/localtime:ro \
 8  -v /var/run/docker.sock:/var/run/docker.sock \
 9  --restart=always \
10  jenkinsci/blueocean

访问

http://localhost:8080

显示初始密码

1docker exec -ti <容器名称> sh
2cat /var/jenkins_home/secrets/initialAdminPassword

工作流程

  1. 先定义一个流水线项目,指定项目的 git 位置
  2. git 位置自动拉取代码
  3. 解析拉取代码里面的 Jenkinsfile 文件
  4. 按照 Jenkinsfile 指定的流水线开始加工项目

Jenkinsfile 语法

基础语法,在仓库创建一个 Jenkinsfile 文件

 1pipeline {
 2    /* 全部的CICD流程都在这里定义 */
 3
 4    //任意代理可用就可以执行
 5    agent any
 6    //定义流水线的加工流程
 7    stages {
 8        /* 流水线的所有阶段
 9            1.编译 "常量"'变量'
10            2.测试
11            3.打包
12            4.部署
13        */
14
15        stage('代码编译'){
16            steps {
17                //要做的所有事情
18                echo "编译……"
19            }
20        }
21
22        stage('代码测试'){
23            steps {
24                //要做的所有事情
25                echo "测试……"
26            }
27        }
28
29        stage('打包'){
30            steps {
31                //要做的所有事情
32                echo "打包……"
33            }
34        }
35
36        stage('部署'){
37            steps {
38                //要做的所有事情
39                echo "部署……"
40            }
41        }
42    }
43}

构建远程触发

  1. 在 jenkins 上选择:项目->配置->构建触发器->勾选触发远程构建
    远程触发

  2. 新疆 gitlab 账户,登录新用户并天剑 token 令牌
    远程触发
    远程触发

  3. 找到 gitlab 设置->webhook
    远程触发
    网站格式

http://<USER>:<TOKENAPI>@<JENKINS-URL>/job/test-blog-demo/build?token=<TOKEN>