Jenkins 在多分支管道中使用withCredentials块时“sh:sh:未找到命令”
我正在建立一个Jenkins multibranch管道,使用Fastlane为Crashlytics构建一个iOS应用程序。现在,Crashlytics的API密钥和build secret以明文形式存储在我的Fastfile中,因此我想将它们移到Jenkins凭据中,以便任何访问我的GitHub repo的人都无法获得这些信息 我按照详细说明创建凭据并从Jenkins文件访问它们。我将它们创建为“机密文本”类型的凭据。Jenkins没有足够的代表发布图片,所以有一些链接: 以下是我如何访问Jenkins文件中的这些凭据:Jenkins 在多分支管道中使用withCredentials块时“sh:sh:未找到命令”,jenkins,groovy,jenkins-pipeline,Jenkins,Groovy,Jenkins Pipeline,我正在建立一个Jenkins multibranch管道,使用Fastlane为Crashlytics构建一个iOS应用程序。现在,Crashlytics的API密钥和build secret以明文形式存储在我的Fastfile中,因此我想将它们移到Jenkins凭据中,以便任何访问我的GitHub repo的人都无法获得这些信息 我按照详细说明创建凭据并从Jenkins文件访问它们。我将它们创建为“机密文本”类型的凭据。Jenkins没有足够的代表发布图片,所以有一些链接: 以下是我如何访问
pipeline {
agent any
stages {
...
stage('Deploy Patient App') {
steps {
withCredentials([
string(credentialsId: 'crashlytics_api', variable: 'api_token'),
string(credentialsId: 'crashlytics_build', variable: 'build_secret')
]) {
sh '''
set +x
bundle exec fastlane deploy app:\'Therapy\' api_token:$api_token build_secret:$build_secret
'''
}
}
}
...
}
}
现在,当我在Jenkins中运行管道时,我得到以下输出:
[Pipeline] stage
[Pipeline] { (Deploy Patient App)
[Pipeline] withCredentials
Masking supported pattern matches of $api_token or $build_secret
[Pipeline] {
[Pipeline] sh
sh: sh: command not found
我在詹金斯档案中做错了什么?还是别的地方出了问题?我也是新来的,但我想看看我能不能帮上忙 我做了一些研究发现: 虽然这是另一个插件,但我注意到它们的相似之处在于它们也使用声明性管道,并且不需要脚本{}块 用您的代码替换Github注释中的差异,如下所示:
stage('Deploy Patient App') {
steps {
withCredentials([
string(credentialsId: 'crashlytics_api', variable: 'api_token'),
string(credentialsId: 'crashlytics_build', variable: 'build_secret')
]) {
sh 'bundle exec fastlane deploy app:\'Therapy\' api_token:$api_token build_secret:$build_secret'
}
}
}
另一个建议是使用双引号,否则他们将收到script.sh:错误的替换错误
PS:抱歉,我自己无法测试这段代码,但它确实在Github上获得了很多支持票。希望这有帮助