Fondamentalement, à l'intérieur de l'itérateur, je mets une variable en utilisant le script (nom: setValue) médiateur. J'essaie d'y accéder dans le script Ruby en dehors de l'itérateur.wso2esb- accès à une variable en dehors de l'itérateur médiateur
Selon la documentation: How to access property mediator outside iterator which is defined inside iterator?
Différentes options J'ai essayé:
1) dans le script Ruby, j'ai essayé d'utiliser
$mc.get-property('Operation','githubhosturl1'); I am getting syntax error at operation.
2) En dehors Iterator J'ai essayé d'y accéder en utilisant la propriété
<property expression="get-property('operation','githubhosturl') name="githubhosturl1)
en obtenant une erreur à l'expression.
3) dans le script Ruby j'ai essayé:
$ mc.get-propriété ('githubhosturl1') - Valeur vide retour
Comment puis-je résoudre ce problème?
Mon code - service proxy - Je ne colle qu'une petite partie, en cas de problème. Dans le script setValue, je peux imprimer la valeur dans le journal de la console.
<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>
S'il vous plaît lire [Dans quelles circonstances puis-je ajouter "urgent" ou d'autres phrases similaires à ma question, afin d'obtenir des réponses plus rapides?] (// meta.stackoverflow.com/q/326569) - le résumé est que ce n'est pas un C'est le moyen idéal de s'adresser à des bénévoles et il est probablement contreproductif d'obtenir des réponses. Merci de ne pas ajouter ceci à vos questions. – halfer