Skip to content
On this page

pipeline - Jenkinsfile

从一个简单的示例开始:

pipeline {
    agent any
    stages {
        stage('Example') {
            steps { 
                echo 'Hello World'
            }
        }
    }
}
pipeline {
    agent any
    stages {
        stage('Example') {
            steps { 
                echo 'Hello World'
            }
        }
    }
}

常用选项说明

pipeline {
    agent any
    environment { 		// 全局变量
        CC = 'clang'
    }
    stages {
        stage('Example') {
            environment { 
                AN_ACCESS_KEY = credentials('my-prefined-secret-text') 		// 局部变量
            }
            steps {
                sh 'printenv'
            }
        }
    }
}
pipeline {
    agent any
    environment { 		// 全局变量
        CC = 'clang'
    }
    stages {
        stage('Example') {
            environment { 
                AN_ACCESS_KEY = credentials('my-prefined-secret-text') 		// 局部变量
            }
            steps {
                sh 'printenv'
            }
        }
    }
}

参考链接