jenkins Pipline knife Kaiushi

The "jenkins Pipline Paodingjieniu" Sharing is a combination of practical work examples to explain.

The main contents are as follows:

  • Pipline grammar explanations
  • Pipline project combat -Maven JAVA building project
  • Pipline project combat -NodeJS building project
  • Share a multilingual build small chestnut Pipeline

1. Pipline composition

Jenkins Pipeline (or simply "Pipeline", a capital letter "P") is a set of plug-in support and integration Jenkins continuous delivery pipeline

A continuous delivery (CD) pipeline is up to your users and customers automate the process of moving from version control software of expression. Each time the software changes (submitted in source control) will go through a complex process in the course of publication. This process involves a reliable and repeatable way to build software, and (called "build") through multiple test and deployment phases to promote the construction software.

Pipeline provides a set of tools can be extended for a domain-specific language through line (DSL) Syntax "as a code" simple to complex modeling of the transport pipeline.

Jenkins duct defined is written to a text file (called a Jenkinsfile), the files can then be submitted to the repository source control program. This is the basis "as a code pipe"; the CD pipelines seen as part of the application, so like any other code as version control and review.

2. Why use pipeline?

Pipeline five properties

Code: Pipeline realized in the form of code, commonly checked into source control, so that the team can edit, censor their CD and iterative process.

Sustainability: Jenklins restart or after an interruption will not affect Pipeline Job.
Pause: Pipeline can choose to stop working and wait for either input or approval, and then continue Pipeline operation.

Multifunction:
Pipeline CD support complex real-world requirements, including the fork / join sub-process, and the ability to parallel execution cycle to work

Scalable: Pipeline Support for custom plug-ins to expand its DSL and multiple options for integration with other plug-ins.

3. Pipeline syntax

- Declarative Declarative

- Scripted pipeline scripted

4. Pipline Declarative format

pipeline {
    agent any 
    stages {
        stage('Build') { 
            steps {
                sh 'echo Build'
            }
        }
        stage('Test') { 
            steps {
                sh 'echo Test'
​
            }
        }
        stage('Deploy') { 
            steps {
                sh 'echo Deploy'
            }
        }
    }
}

pipeline: the representative of the whole line, the logic comprising the entire pipeline.

Part stages: a pipeline stage in a plurality of containers. comprising at least a portion of stages stage.

stage parts: the stage, on behalf of the pipeline stage. Each stage must have a name. In this example, build is the name of this stage.

Representative of one or more stages: steps part

5. Scripted Pipeline

Scripted Pipeline requirements of grammar more relaxed, the top layer can be a node, it can also be a stage. node can be nested stage, stage in turn, can also be nested node. A typical scripted Pipeline syntax is as follows:

node {   //node可以指定label 例如 node ('label_name') {}
    stage("Build") {
        sh 'echo Building...'
    }

    stage("Test"){
        sh 'echo Testing...'
    }
}

6. Pipline Declarative Parameter Description

......

7. Pipline support instruction

......

Waiting for the update, if necessary, details of private letter I get

Guess you like

Origin blog.51cto.com/51reboot/2437223