Jenkins 管道上的多步 shell 命令

bud*_*ano 5 groovy jenkins jenkins-pipeline

我有一个詹金斯工作,有一个包含以下命令的 shell 步骤。运行得很棒!

sudo yum install python36
virtualenv -p python3 test
source test/bin/activate
<some other command>
Run Code Online (Sandbox Code Playgroud)

现在我想把它变成一个管道。我如何在 groovy 中编写相同的内容?我尝试使用这样的语法但失败了:

stage('Test') {
        steps {
            sh 'sudo yum install python36'
            sh 'virtualenv -p python3 test'
        }
    }
Run Code Online (Sandbox Code Playgroud)

Nic*_*lay 5

为了执行多个 shell 命令,您需要将它们括在一对三个单引号中'''

stage('Test') {
        steps {
            sh '''
               sudo yum install python36
               virtualenv -p python3 test
               '''
        }
}
Run Code Online (Sandbox Code Playgroud)