#!/usr/bin/env groovy /* 使用声明式流水线 方式*/ pipeline { /* Jenkins为流水线分配一个执行器和工作区*/ agent any environment{ hello= 'hello' world="""${sh(returnStatus:true, script:'echo "world"')} """ } stages { stage('echo'){ steps{ script{ def singlyQuoted='hello' def doublyQuoted="world" echo 'hello mr. ${singlyQuoted}' echo "i said hello mr. ${doublyQuoted}" } echo "${world}" } } stage('read environment'){ steps{ echo "${env.BUILD_ID}" echo '---------------------------' // echo ${env.BUILD_ID} } } stage('Git Checkout') { steps { checkout([$class: 'GitSCM', branches: [[name: '$Branches']], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'Default', submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a97e0ce1-814b-4e7d-832a-4ac3eed72506', url: 'git@gitlab.schbrain.com:zhangdongdong/test.git']]]) } } stage('build') { steps { sh "/var/jenkins_home/tools/apache-maven-3.6.3/bin/mvn clean -U package -Dversion=${version} -Dmaven.test.skip=true -P${profiles}" } } stage('test') { steps { echo 'testing ...' } } stage('deploy') { steps { echo 'deploy...' } } } }