[英]Podtemplate() not accepting the yaml file using readFile or yamlFile
我的代码:
podTemplate(label: slave_label, cloud: ${cloud_name}, readFile : 'deploy.yml') {
}
我使用 yamlFile 和 readFile 也不接受输入。 bddrunner pod 未启动
当我使用这种直接的 yaml 方法时,它工作正常。 像这样:
podTemplate(label: slave_label, cloud: ${cloud_name}, yaml: """ """) {
}
我怎样才能解决这个问题?
https://github.com/jenkinsci/kubernetes-plugin#using-yaml-to-define-pod-templates
yaml: readFile('path-to-file')
必须注意, readFile 只能在活动工作区中工作。 这意味着您必须在 Node 部分。 https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#readfile-read-file-from-workspace
你的代码应该是:
podTemplate(label: slave_label, cloud: ${cloud_name}, yaml: readFile('deploy.yml')) {
}
编辑:更正了从yamlFile:
到yaml:
大脑拼写错误。
yamlFile
不应在 Jenkins 脚本管道中使用。
本周我遇到了这个问题,无法快速找到正确的解决方案。
根据插件文档( https://github.com/jenkinsci/kubernetes-plugin#pod-and-container-template-configuration )加载 yaml 文件,您应该使用readFile
或readTrusted
。 这对于脚本化管道来说是错误的,因为只有当您已经拥有代理 pod 时才能使用这些命令(因此“您不能咬自己的尾巴”)。
我找到的解决方案是将所有 yaml 像maven-build-release.yaml
放在resources/
文件夹中,并在libraryResource
帮助下加载所需的配置,如下所示:
[...]
podTemplate(
yaml: libraryResource('maven-build-release.yaml')) {
node(POD_LABEL) {
stage('Clone Source Code (Git)') {
[...]
选项是yamlFile
not readFile
看这个例子https://github.com/jenkinsci/kubernetes-plugin/blob/master/examples/declarative_from_yaml_file/Jenkinsfile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.