[英]How to read multiple attributes using xpath and based on that trigger the jenkins job
I am having an xml file(executeRM.xml) with contents as mentioned below. 我有一个xml文件(executeRM.xml),其内容如下所述。
<r1> <n1 name="component1" version="14.0" state="ToBeInstalled"/> <n2 name="Component2" version="13.0" state="Installed"/> <n3 name="Component3" version="12.0" state="TobeInstalled"></r1>
I have used "FS trigger-Monitor files" and is an every one minute schedule, where I have given the full path of the above xml file. 我使用了“FS触发器 - 监视文件”并且每隔一分钟安排一次,我已经给出了上述xml文件的完整路径。 Now I want to write an xpath query, which will trigger the job only when state will be "ToBeInstalled" for any of the 3 components or all.
现在我想编写一个xpath查询,只有在状态为3个组件或全部的任何一个组件的“ToBeInstalled”时才会触发该作业。 I have written the below xpath query, but the job itself is not getting triggered.
我编写了下面的xpath查询,但作业本身没有被触发。
/r1/n1[@name='Component1' and @state='ToBeInstalled'] /r1/n2[@name='Component2' and @state='ToBeInstalled'] /r1/n3[@name='Component3' and @state='ToBeInstalled']
According to the FSTrigger help: 根据FSTrigger的帮助:
Poll the content of the specified XML file.
轮询指定XML文件的内容。 You have to give XPath expressions.
你必须给XPath表达式。 A build is triggered if the value of XPath expressions have changed between 2 polls.
如果XPath表达式的值在2个轮询之间发生更改,则会触发构建。
Are you sure your xPath 你确定你的xPath
/r1/n1[@name='Component1' and @state='ToBeInstalled'] /r1/n2[@name='Component2' and @state='ToBeInstalled'] /r1/n3[@name='Component3' and @state='ToBeInstalled']
is correct? 是正确的? what you have seems like 3 separate xPaths.
你有什么看起来像3个独立的xPaths。
Even if you just use /r1/n1[@name='Component1' and @state='ToBeInstalled']
this just selects n1, a node that has no text value, so it never changes (that's just my theory). 即使你只使用
/r1/n1[@name='Component1' and @state='ToBeInstalled']
这只选择n1,一个没有文本值的节点,所以它永远不会改变(这只是我的理论)。
I was able to get it to trigger by just using /r1/n1/@state
for example, but I don't think this will give the control you want (and you may get multiple builds triggered). 例如,我只能使用
/r1/n1/@state
来触发它,但我不认为这会给你想要的控件(并且你可能会触发多个构建)。
I think you need more information on how the value of XPath expression is evaluated. 我认为您需要有关如何评估XPath表达式的值的更多信息。 You might ask the maintainer for further information at the plugin site .
您可以在插件站点向维护者询问更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.