jenkins - 将字符串参数传递给 Jenkins 声明性脚本
问题描述
我在 Jenkins 中声明一个字符串参数 -
Name is SLACKTOKEN
Value is qwsaw2345
我的 Jenkins 文件有脚本
pipeline {
agent { label 'trial' }
stages {
stage("Build Docker Image") {
steps{
sh 'docker build -t trial:latest --build-arg SLACK_SIGNING_SECRET=${SLACKTOKEN}'
}
}
}
}
我试过这样,但它没有用。您能否让我知道如何将 Jenkins 字符串参数中的值传递给 Jenkins 声明性脚本文件。我在工作中添加了密码参数,如下所示
解决方案
在parameters
指令里面你可以提供参数,细节在这里。
params.SLACKTOKEN
在双引号内传递参数使用,而不是单引号:
pipeline {
agent { label 'trial' }
parameters {
password(name: 'SLACKTOKEN', defaultValue: '', description: 'Slack Token')
}
stages {
stage("Build Docker Image") {
steps{
sh "docker build -t trial:latest --build-arg SLACK_SIGNING_SECRET=${params.SLACKTOKEN}"
}
}
}
}
推荐阅读
- java - 是否有具有 2 个索引 / 一个键键数据结构的数据结构?
- python - 如何添加另一个数据框的索引
- java - 单击时未显示微调器选定的项目
- javascript - 我可以使用源映射和捆绑文件来检索原始反应代码吗
- mysql - 组合键作为另一个表的外键,组合键作为主键
- java - 应用程序未将日志保存到特定的附加程序
- mysql - 使用内部联接在 SELECT 中设置别名
- dictionary - 如何使用 foreach 和 IF 语句运行循环以检查输入值在字典中找到
- html - WCAG 2.0 冗余链接
- python - 在本地运行烧瓶与在 AWS Elastic BeanStalk 上运行它 - 一些范围问题?