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