jenkins-pipeline - 如何在 jenkinsfile 中声明变量
问题描述
我正在尝试从 jenkinsfile 中的变量中获取 repo 详细信息。有人可以指导为什么这不起作用吗?
parameters {
string(defaultValue: "develop", description: 'enter the branch name to use', name: 'branch')
string(defaultValue: "repo1", description: 'enter the repo name to use', name: 'reponame')
}
stage('Branch Update'){
dir("${param.reponame}"){
bat """ echo branch is ${params.branch}"""
}
}
当我运行上述内容时,我收到以下错误消息:
groovy.lang.MissingPropertyException:没有这样的属性:类的参数:groovy.lang.Binding [Pipeline] }
解决方案
你有一个错字。而不是param.reponame
应该是params.reponame
.
推荐阅读
- chart.js - 如何限制chart.js中显示的点数?
- php - 我的 Ajax 不显示通知消息
- php - 如何声明在 PhpDoc 中定义了一个常量(用于 intelephense)?
- string - string.Contains 函数在我的 golang 代码中没有按预期工作。虽然第一个字符串包含第二个字符串,但条件失败
- python - 使用 Beautiful Soup 获取标签相交的内容全文
- swift - 如何对 VoiceOver 手势进行自动化测试,例如“Perform Escape”?
- python - Pygame 出现故障
- excel - 用于删除具有空列的行并在 Excel 电子表格中选择特定列的公式
- python-3.x - 使用 OpenCv 的阈值?
- clojure - 如何在 LightTable 中使用 Clojure 中的库