Jenkins Pipeline 使用及调试

1. 基本概念

  • master
1
2
npm install -g jenkins-pipeline
apm install build

可以看到脚本 test.groovy 能够被执行,同时在 Jenkins 的后台界面中,也可以看到构建的执行详情,而 MyTest 项目中 pipeline 脚本内容已经被更新为 test.groovy 的内容。

  • Atom 安装 Build 插件后,配置.atom-build.yml,新增如下内容:

1
2
3
4
5
6
cmd: "jenkins-pipeline"
args:
  - "--file {FILE_ACTIVE}"
  - "--url http://yourdomain.com:8080/job/MyTest/"
  - "--credentials admin:123456"
sh: true

3. Jenkins 中使用 pipeline

4.1 关键字

  • stage 顺序执行
node("master"){
    stage 'one'
    echo "start one"
    sleep 1

    stage 'two'
    echo "start two"
    sleep 3

    stage 'three'
    echo "start three"
    sleep 5
}