我正在运行 Jenkinsfile 从远程服务器 grep pm2 服务,因此我使用 grep 实用程序来查找 pm2 服务名称。尽管如此,Jenkins Groovy 仍不理解 bash 命令,并在构建管道之前给出错误。
这是我的管道
pipeline {
agent any
parameters {
string(defaultValue: '', description: 'List of PM2 applications', name: 'PM2_Applications')
}
stages {
stage('SSH transfer') {
steps([$class: 'BapSshPromotionPublisherPlugin']) {
sshPublisher(
continueOnError: false, failOnError: true,
publishers: [
sshPublisherDesc(
configName: "server-config",
verbose: true,
transfers: [
sshTransfer(execCommand: "pm2 ls | grep -vE '^\s*id\s+' | awk '{print $4}'"),
]
)
]
)
}
}
}
}
我遇到的错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 18: unexpected char: '\' @ line 18, column 75.
Command: "pm2 ls | grep -vE '^\s*id\s+'
预期输出: 它应该使用 grep 运行 pm2 命令,它将给出命令的实际输出。