0
基本上,在迭代器内部,我使用Script(name:setValue)mediator设置了一些变量。我试图在迭代器之外的Ruby脚本中访问它们。wso2esb - 访问迭代器以外的变量mediator
根据文档:How to access property mediator outside iterator which is defined inside iterator?
不同的选择我想:
1)在Ruby脚本,我尝试使用
$mc.get-property('Operation','githubhosturl1'); I am getting syntax error at operation.
2)外的Iterator我试着用房产
访问它们<property expression="get-property('operation','githubhosturl') name="githubhosturl1)
在表达式中收到错误。
3)在Ruby脚本,我想:
$ mc.get属性( 'githubhosturl1') - 空值返回
我怎样才能解决这个问题呢?
我的代码 - 代理服务 - 我粘贴只有一小部分,哪里有问题。在setValue脚本中,我可以在控制台日志中打印值。
<Iterator>
-------
--------
-------
<script description="setValue" language="js"><![CDATA[var log = mc.getServiceLog();
var tool = mc.getProperty('toolList');
if(tool == "github")
{
var vhosturl = mc.getProperty('catName');
mc.setProperty('githubhosturl',vhosturl.toString());
var vassetid = mc.getProperty('assetidval');
mc.setProperty('gitassetid',vassetid.toString());
var vbranch="qa";
mc.setProperty('gitbranch',vbranch.toString());
}
if(tool == "dockercloud")
{
var vhosturl = mc.getProperty('catName');
mc.setProperty('dockerhosturl',vhosturl.toString());
var vassetid = mc.getProperty('assetidval');
mc.setProperty('dockerid',vassetid.toString());
var creid = mc.getProperty('jsondata');
mc.setProperty('doccredid',creid.toString());
var vprojName = mc.getProperty('projName');
mc.setProperty('docproj',vprojName.toString());
}]]></script>
<property expression="get-property('githubhosturl')" name="githubhosturl1" scope="operation" type="STRING"/>
<property expression="get-property('gitbranch')" name="gitbranch1" scope="operation" type="STRING"/>
<property expression="get-property('gitassetid')" name="gitassetid1" scope="operation" type="STRING"/>
<property expression="get-property('dockerhosturl')" name="dockerhosturl1" scope="operation" type="STRING"/>
<property expression="get-property('doccredid')" name="doccredid1" scope="operation" type="STRING"/>
<property expression="get-property('docproj')" name="docproj1" scope="operation" type="STRING"/>
</sequence>
</target>
</iterate>
<script description="re" language="rb"><![CDATA[require 'erb'
require 'erb'
@giturl = $mc.getProperty('githubhosturl1');
@gitbranch = $mc.getProperty('gitbranch1');
@gitcredential = $mc.getProperty('gitassetid1');
@dockerurl = $mc.getProperty('dockerhosturl1');
@dockerCred = $mc.getProperty('doccredid1');
@dockerprojectname = $mc.getProperty('docproj1');
@template = File.read('C:\WS02\workspace\index.txt.erb')
OutTemplate = ERB.new(@template).result(binding)
File.open('C:\WS02\workspace\Jenkin.groovy',"w") do |f|
f.puts OutTemplate
end]]></script>
请阅读[在什么情况下,我可以添加“紧急”或其他类似的短语到我的问题,以获得更快的答案?](/ meta.stackoverflow.com/q/326569) - 摘要是,这不是一个解决志愿者的理想方式,并且可能会对获得答案产生反作用。请不要将这添加到您的问题。 – halfer