jenkins pipeline 报 unexpected char: '\' 错误
问题:
在写jenkins pipeline script的时候,如果字符里面有\
字符,比如这样:
pipeline {
agent any
stages {
stage('Check virtualenv') {
steps {
sh """
rm -r /mnt/x/some/directory/Problem\ 1.0/path
"""
}
}
}
}
会提示一个错误:WorkflowScript: 4: unexpected char: '\'
解决方法:
\
字符是 Groovy 中的一个特殊字符。如果需要这个\
字符,可以这样写:
pipeline {
agent any
stages {
stage('Check virtualenv') {
steps {
sh """
rm -r /mnt/x/some/directory/Problem\\ 1.0/path
"""
}
}
}
}