Shell脚本无法读取Groovy变量,尝试了多种方法
我是Shell和Groovy的新手,并且我已经在下面搜索并阅读了解决方案,但似乎都没有工作
Groovy参数到Shell脚本 通过Groovy变量到Shell Script 读取文件到变量shell脚本 詹金斯 如何将Groovy Variable传递给Jenkinsfile中的shold script /a>
问题: 我想从Groovy变量中读取价值并将其传递给Shell脚本,但是我要么获得空白值,
要么以下文字变量名称是我的代码:
def Tenant_Instances = ''
//some more declarations and code
if(tenant_created)
{
Tenant_Instances = "author.${ciTenant}.rally-dev.com,publish.${ciTenant}.rally-dev.com"
println("tenant instance are -"+Tenant_Instances) //value coming fine here
//some code here
println("tenant instance again are -"+Tenant_Instances) //values coming fine here too
sh '''#!/bin/bash
echo "[MNR] - Beginning deployment of bundle(s) to AEM Package Manager"
IFS="," read -ra INSTANCES <<< $Tenant_Instances
echo "demo ${INSTANCES}" -->here value does not come properly
我尝试用'tenant_instances'替换tenant_instances'或“ $ {tenant_instances}”或$ {tenant_instances}”或“ $ tenant_instances” ...但似乎都没有用。
I am new to shell and groovy and I have already googled and read solutions below, but none of it seems to be working
Groovy parameter to shell script
Pass groovy variable to shell script
read file to variable shell script
How to pass a groovy variable to a shell block jenkins
How to pass groovy variable to shell script in Jenkinsfile?
Issue:
I want to read value from the groovy variable and pass it to shell script but either I get blank value or the literal variable name
Below is my code:
def Tenant_Instances = ''
//some more declarations and code
if(tenant_created)
{
Tenant_Instances = "author.${ciTenant}.rally-dev.com,publish.${ciTenant}.rally-dev.com"
println("tenant instance are -"+Tenant_Instances) //value coming fine here
//some code here
println("tenant instance again are -"+Tenant_Instances) //values coming fine here too
sh '''#!/bin/bash
echo "[MNR] - Beginning deployment of bundle(s) to AEM Package Manager"
IFS="," read -ra INSTANCES <<< $Tenant_Instances
echo "demo ${INSTANCES}" -->here value does not come properly
I have tried replacing Tenant_Instances with 'Tenant_Instances' or "${Tenant_Instances}" or $Tenant_Instances or '$Tenant_Instances'... but none of it seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论