Jenkins created the pipeline pipeline
What is pipeline? Simply speaking, it is a set of workflow framework running on Jenkins, which connects the tasks originally running on a single or multiple nodes to realize the release process that is difficult to be completed by a single task. (Usage scenario: Easily integrate multiple Jenkins build tasks)
Practical significance of pipeline
Build pipeline Task
- Make sure the pipeline plug-in is installed. If not, go to “System Administration -> Plug-in Management” to search for the installation
- Create a pipeline job
3. Once created, try writing a simple pipeline script
4. The job is saved successfully
5. Use the line syntax. Click the line syntax in the figure above to automatically generate the corresponding command, and then replace the command with step
A brief introduction to pipeline syntax
pipeline {
agent any
stages {
stage('test') {
steps {
build 'maventest'
}
}
}
}
Copy the code
agent
Execute Pipeline or stage on any available agent. For example, agent any. There are other parameters that can be followed by agent, such as none, label, node, docker
- None: When None is used at the top of a pipeline block, the global Agent will not be assigned to the entire Pipeline run, and each stage part will need to contain its own Agent part.
- Label: Perform Pipeline or stage on the agent available in the Jenkins environment using the supplied label label. For example: agent {label’ my-defined-label’}
- Node: Agent {node {label ‘labelName’}}, equivalent to Agent {label ‘labelName’}, but node allows other options (such as customWorkspace).
- Docker: < span style = “box-sizing: border-box; line-height: 22px; display: block; word-break: inherit! Important; word-break: inherit! Important;” Docker can also accept an args, which is passed directly to the Docker run call. For example: agent {docker ‘maven:3-alpine’}
stages
- A sequence containing one or more stages, where most of the work of a Pipeline is performed. It is recommended that stages contain at least one stage directive that connects delivery processes such as build, test, and deployment.
step
- Steps contains one or more sequences of steps that are executed within the Stage block.
conclusion
- The most basic part of a Pipeline is the “step”. Basically, the step tells Jenkins what to do and serves as the basic building block for the Declarative Pipeline and Scripted Pipeline syntax.
- Pipelines support two syntax: Declarative Pipelines (introduced in Pipeline 2.5, structured way) and Scripted Pipelines, both of which support building continually-pumped pipelines.
- All valid Declarative pipelines must be contained within a Pipeline block, for example:
pipeline { /* insert Declarative Pipeline here */ }
Copy the code
-
Basic statements and expressions in Declarative Pipeline follow the same rules as Groovy syntax, with the following exceptions:
A. Pipeline’s top layer must be a block, specifically: pipeline {}
B. There is no semicolon as statement separator. Each declaration must be on its own line
C. Blocks can only contain Sections, Directives, Steps or assignment statements.
reference
- Cloud.tencent.com/developer/a…
- Testingpai.com/article/160…
- www.jianshu.com/p/75090154d…