「Jenkins Pipeline」- 使用 Jenkinsfile 文件(学习笔记)

  CREATED BY JENKINSBOT

本笔记内容是对 Jenkins/Pipeline/Using a Jenkinsfile 手册的学习整理。

Table of Contents

Creating a Jenkinsfile

Build
Test
Deploy

Working with your Jenkinsfile

String interpolation

Using environment variables

Setting environment variables
Setting environment variables dynamically

Handling credentials

For secret text, usernames and passwords, and secret files

Secret text

Usernames and passwords

Secret files

For other credential types

Combining credentials in one step

Handling parameters

Handling failure

Using multiple agents

Optional step arguments

Advanced Scripted Pipeline

Parallel execution

脚本式流水中定义环境变量:

node {
    withEnv(["PATH+MAVEN=${tool 'M3'}/bin"]) {
        sh 'mvn -B verify'
    }
}

Pipeline Syntax reference

Pipeline Syntax

Pipeline Steps reference

Pipeline Steps Reference

retry – 重复执行,直至成功

Pipeline: Basic Steps/retry

retry(5){
     httpRequest(url: 'https://www.google.com')
}

参考文献

Jenkins/Pipeline/Using a Jenkinsfile