持续集成流水线实战指南
1. 创建 Jenkinsfile
首先,我们可以创建一个 Jenkinsfile 并将其推送到 GitHub 仓库。其内容与我们之前编写的提交管道几乎相同,唯一的区别在于检出阶段变得多余,因为 Jenkins 必须先检出代码(包括 Jenkinsfile),然后再读取管道结构(从 Jenkinsfile 中)。这就是为什么 Jenkins 在读取 Jenkinsfile 之前需要知道仓库地址。
在项目的根目录下创建一个名为 Jenkinsfile 的文件,内容如下:
pipeline {
agent any
stages {
stage("Compile") {
steps {
sh "./gradlew compileJava"
}
}
stage("Unit test") {
steps {
sh "./gradlew test"
}
}
}
}
接着,我们可以提交添加的文件并推送到 GitHub 仓库:
$ git add .
$ git commit -m "Add sum Jenkinsfile"
$ git push
2. 从 Jenkinsfile 运行管道
当
超级会员免费看
订阅专栏 解锁全文
1123

被折叠的 条评论
为什么被折叠?



