Matrix configuration with Jenkins pipelines

后端 未结 5 1949
青春惊慌失措
青春惊慌失措 2020-12-24 12:12

The Jenkins Pipeline plugin (aka Workflow) can be extended with other Multibranch plugins to build branches and pull requests automatically.

What would

5条回答
  •  旧巷少年郎
    2020-12-24 13:13

    I would suggest Declarative Matrix as a preferred way to run multiple configurations in Jenkins. It allows you to execute the defined stages for every configuration without code duplication.

    Example:

    pipeline {
        agent none
        stages {
            stage('Test') {
                matrix {
                    agent {
                        label "${NODENAME}"
                    }
                    axes {
                        axis {
                            name 'NODENAME'
                            values 'java7node', 'java8node'
                        }
                    }
                    stages {
                        stage('Test') {
                            steps {
                                echo "Do Test for ${NODENAME}"
                            }
                        }
                    }
                }
            }
        }
    }
    

    Note that declarative Matrix is a native declarative Pipeline feature, so no additional Plugin installation needed.

    Jenkins blog post about the matrix directive.

提交回复
热议问题