3
【笔记】Jenkins 创建流水线项目
source link: https://loli.fj.cn/2023/07/27/Jenkins%E5%88%9B%E5%BB%BA%E6%B5%81%E6%B0%B4%E7%BA%BF%E9%A1%B9%E7%9B%AE/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Jenkins 创建流水线项目
Manage Jenkins
->Plugins
->Available plugins
-> 搜索并安装Pipeline
、Pipeline: Stage View
、Pipeline: GitHub Groovy Libraries
插件
创建流水线项目
编写 Pipeline 脚本
agent
:指定任务的构建在哪个集群节点,any 表示任何节点environment
:定义全局变量
pipeline {
agent any
environment {
key = 'value'
}
stages {
stage('操作名1') {
steps {
...
echo '操作1完成'
}
}
stage('操作名2') {
steps {
...
echo '操作2完成'
}
}
}
}
生成 Pipeline 脚本
- 选择
流水线语法
- 配置具体操作内容 ->
生成流水线脚本
-> 复制生成后的脚本
- 将制作好的流水线脚本粘贴到
steps{}
内 ->保存
构建并查看日志
立即构建
-> 等待构建完成 -> 鼠标放到节点上,点击Logs
查看日志
将 Pipeline 脚本放到 Git 中管理
创建 Jenkinsfile 文件
- 在 Git 管理的项目中创建
Jenkinsfile
文件用于编写 Pipeline 脚本
pipeline {
...
}
在 Jenkins 上指定包含 Jenkinsfile 文件的 Git 仓库
- 如果 Pipeline 脚本文件名不为
Jenkinsfile
或者 Pipeline 脚本文件没有存放到 Git 仓库根目录,则需要手动指定脚本路径
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK