Cruisecontrol.net how I can get value of a parameter and pass into Labeller plugin - cruisecontrol.net

<project name="My Project" queue="1" queuePriority="1">
<labeller type="MyLabeller">
<MyNumber>myProject_${MyNumber}</MyNumber>
</labeller>
<parameters>
<selectParameter name="MyNumber">
<description>Select RC number</description>
<display>RC build</display>
<allowedValues>
<value name="None">0</value>
<value name="data1">1</value>
<value name="data2">2</value>
</allowedValues>
<default>0</default>
<required>true</required>
</selectParameter>
</parameters>
</project>
I wrote a Labeller plugin named MyLabeller. I want when user choose MyNumber in UI when they force a new build. The value of MyNumber will be passed into MyLabeller plugin. I try to use the following syntax but no luck.
myProject_${MyNumber}
If user choose 1, My Number has to be myProject_1.
if user choose 2, My Number has to be myProject_2.
So are there any ways to do this ? Thanks.
p/s: currently, I use cruisecontrol.net version 1.8.4.0

parameter references use square brackets $[parameter name]
Be ware that parameters are not updated for pre-build.
You can also set environemnt variable ... value = $[parameter name] within an executable task but remember the variable value will only exist for the duration of the executable command.

Related

How do i fix the error in replace regex flag component?

I am using nutch 1.14 since I am using GCS indexer. Here is what I have in nutch-site.xml
<property>
<name>index.replace.regexp</name>
<value>
urlmatch=.*example.com\/[a-zA-Z0-9-]+
url:category=/https:\/\/www.example.com\/([a-zA-Z0-9-]+)/$1/
</value>
</property>
I am getting the error:
$ grep 'replace' logs/hadoop.log
ERROR replace.ReplaceIndexer - Pattern
url:category=/https:\/\/www.example.com\/([a-zA-Z0-9-]+)/$1/, has invalid flags component
I get the same when i change the line in nutch-site.xml to:
-url:category=/https:\/\/www.mydomain.com\/([a-zA-Z0-9-]+)/$1/2
I want to get part of url in category. Ex: If url is https://www.example.com/testcategory , i like category to be testcategory
Thanks.
If I understand correctly you want to get what is after the domain (example.com) and place it in a category field, right?
In that case, you have an error in your regex. You want to capture everything after example.com/<category> then you need to configure your urlmatch like:
urlmatch=.*example\.com\/([a-zA-Z0-9-]+)
In this case ([a-zA-Z0-9-]+) will create a capture group accessible through $1. And then you can set the field like:
url:category=$1
This would get what was captured with the capture group and place it a category field.
You can test the regex in: https://regex101.com/r/bMLqOq/1.

How to use cTAKES from the command line?

I wonder how to use Apache cTAKES from the command line.
E.g. :
I have a file note.txt that contains some text like "Patient had
elevated blood sugar but tests confirm no diabetes. Patient's father had
adult onset diabetes."
I want to use the provided analysis engine
\apache-ctakes-3.2.2-bin\apache-ctakes-3.2.2\desc\ctakes-clinical-pipeline\desc\analysis_engine\AggregatePlaintextUMLSProcessor.xml
How can I get the analyse engine's output (viz. the annotations) using the
command line (i.e. without using graphical user interfaces such as UIMA CAS
Visual Debugger or the Collection Processing Engine)? I'd prefer to
use the provided JAR files rather than having to compile the code.
The question is fairly simple but I couldn't find the information in
cTAKES's README or
on Confluence.
Please try the following steps to use cTAKES CPE from the command line (the key class is "org.apache.uima.examples.cpe.SimpleRunCPE"):
Change directory to $CTAKES_HOME/desc/ctakes-clinical-pipeline/desc/collection_processing_engine/
Copy test_plaintext.xml to another file (e.g., "test_plaintext_test.xml").
Edit "test_plaintext_test.xml" to set input directory; find "nameValuePair" with name = "InputDirectory", and set the value string to the input directory. The following example set the input directory as "$CTAKES_HOME/note_input":
<nameValuePair>
<name>InputDirectory</name>
<value>
<string>note_input</string>
</value>
</nameValuePair>
Similarly, edit "test_plaintext_test.xml" to set the output directory ("$CTAKES_HOME/result_output" in the following example):
<nameValuePair>
<name>OutputDirectory</name>
<value>
<string>result_output</string>
</value>
</nameValuePair>
Save "test_plaintext_test.xml" and change directory to $CTAKES_HOME/bin.
Copy runctakesCPE.sh to another file (e.g., "runctakesCPE_CLI.sh").
Edit "runctakesCPE_CLI.sh"; replace the last line ("java ...") to the following line ("USER" and "PW" should be replaced by your UMLS Username and Password, and the memory setting Xms and Xms may be adjusted based on the size of memory on your machine):
java -Dctakes.umlsuser=USER -Dctakes.umlspw=PW -cp $CTAKES_HOME/lib/*:$CTAKES_HOME/desc/:$CTAKES_HOME/resources/ -Dlog4j.configuration=file:$CTAKES_HOME/config/log4j.xml -Xms2g -Xmx3g org.apache.uima.examples.cpe.SimpleRunCPE $CTAKES_HOME/desc/ctakes-clinical-pipeline/desc/collection_processing_engine/test_plaintext_test.xml
Save "runctakesCPE_CLI.sh", and then create the input directory ("$CTAKES_HOME/note_input") and the output directory ("$CTAKES_HOME/result_output").
Put your note.txt to the input directory (e.g., "$CTAKES_HOME/note_input/note.txt"), and then run "runctakesCPE_CLI.sh".
cTAKES CPE will start running under command line mode, and the resulting file will be generated in the output directory (e.g., "$CTAKES_HOME/result_output/note.txt.xml").
I actually used your note.txt to run the steps above and here are the first several lines of the generated note.txt.xml:
<?xml version="1.0" encoding="UTF-8"?><CAS version="2">
<uima.cas.Sofa _indexed="0" _id="3" sofaNum="1" sofaID="_InitialView" mimeType="text" sofaString="Patient had elevated blood sugar but tests confirm no diabetes. Patient's father had adult onset diabetes.
"/>
<org.apache.ctakes.typesystem.type.structured.DocumentID _indexed="1" _id="1" documentID="note.txt"/>
<uima.tcas.DocumentAnnotation _indexed="1" _id="10" _ref_sofa="3" begin="0" end="107" language="x-unspecified"/>
<org.apache.ctakes.typesystem.type.textspan.Segment _indexed="1" _id="15" _ref_sofa="3" begin="0" end="107" id="SIMPLE_SEGMENT"/>
<org.apache.ctakes.typesystem.type.textspan.Sentence _indexed="1" _id="21" _ref_sofa="3" begin="0" end="63" sentenceNumber="0"/>
Hope this helps :-)
java -Dctakes.umlsuser=USER -Dctakes.umlspw=PW -cp $CTAKES_HOME/lib/*;$CTAKES_HOME/desc/;$CTAKES_HOME/resources‌​/ -
Dlog4j.configuration=file:$CTAKES_HOME/config/log4j.xml -Xms2g -Xmx3g to_replace $CTAKES_HOME/desc/ctakes-clinical-pipeline/desc/collection_p‌​rocessing_engine/tes‌​t_plaintext_test.xml
replace "to_replace" with either
org.apache.ctakes.ytex.tools.RunCPE or
org.apache.ctakes.core.cpe.CmdLineCpeRunner

SlowCheetah transform ignores multiple conditions

I have a WCF configuration file that I am trying to transform with SlowCheetah. For development use, we want to include the MEX endpoints, but when we release the product, these endpoints should be removed on all services except one. The server for which it should be left has the following endpoint:
<endpoint address="MEX"
binding="mexHttpBinding"
contract="IMetadataExchange" />
The ones that should be removed are as follows:
<endpoint address="net.tcp://computername:8001/WCFAttachmentService/MEX"
binding="netTcpBinding"
bindingConfiguration="UnsecureNetTcpBinding"
name="WCFAttachmentServiceMexEndpoint"
contract="IMetadataExchange" />
The transform I am using is:
<service>
<endpoint xdt:Locator="Condition(contains(#address, 'MEX') and not(contains(#binding, 'mexHttpBinding')))" xdt:Transform="RemoveAll" />
</service>
However, when I run this, ALL MEX endpoints are removed from the config file including the one that I wish to keep. How do I make this work properly?
The Locator Condition expression that selects the nodes seems to be correct. If you had only the two endpoints you posted in your example, this expression will select the second endpoint.
According to the documentation the Transform attribute RemoveAll should "remove the selected element or elements." Based on the information you posted it's not working as expected, since the first element was not selected and was removed anyway. Based on this StackOverflow answer it seems to me that the issue is with Condition. I'm not sure if that's a bug (it's poorly documented), but you could try some alternative solutions:
1) Using XPath instead of Condition. The effective XPath expression that is applied to your configuration file as a result of the Condition expression is:
/services/service/endpoint[contains(#address, 'MEX') and not(contains(#binding, 'mexHttpBinding'))]
You should also obtain the same result using the XPath attribute instead of Condition:
<endpoint xdt:Locator="XPath(/services/service/endpoint[contains(#address, 'MEX')
and not(contains(#binding, 'mexHttpBinding'))])" xdt:Transform="RemoveAll" />
2) Using Match and testing an attribute such as binding. This is a simpler test, and would be IMO the preferred way to perform the match. You could select the nodes you want to remove by the binding attribute
<endpoint binding="netTcpBinding" xdt:Locator="Match(binding)" xdt:Transform="RemoveAll" />
3) UsingXPath instead of Match in case you have many different bindings and only want to eliminate only those which are not mexHttpBinding:
<endpoint xdt:Locator="XPath(/services/service/endpoint[not(#binding='mexHttpBinding'))" xdt:Transform="RemoveAll" />
4) Finally, you could try using several separate statements with Condition() or Match() to individually select the <endpoint> elements you wish to remove, and use xdt:Transform="Remove" instead of RemoveAll.

Split String from inifile

i've got a question about ant and String split.
In a IniFile i've a section "[app_version]" with 1 element: "VERSION = 3.48".
My goal is to split "3.48" in 3 and 48.
I've try to read the ini file sucessfully with this code and it's work.
<target name="get_new_version_number">
<property file="${basedir}/Ini File/Config.ini" prefix="config.">
</property>
<property name="version_actuelle" value="${config.VERSION}" />
<echo message="version de l'application: ${version_actuelle}"/>
but, how can i split "3.48" witch is my value, in 3 and 48. I need to do this to increment 48 each time i execute the script.
Thanks by advance for your considerations.
Regards.
Simon
thanks for your answer.
I've try your solution but it not work for me because, i've got for result, 3.48.1, 3.48.1.2, 3.48.1.2.3....... etc
I really need to increment "48" so i have to split my value 3.48 with split fonction or something else.
But, again, thanks very much for your time.
regards
Simplest solution would be to read the major number from the ini file and then use the buildnumber task to manage the incrementing number
<buildnumber/>
<echo message="${majorNum}.${build.number}"/>
The Ant addon Flaka provides a split function, f.e. =
<project name="demo" xmlns:fl="antlib:it.haefelinger.flaka">
<property name="yourvalue" value="3.48"/>
<fl:echo>#{split('${yourvalue}', '\.')[0]}${line.separator}#{split('${yourvalue}', '\.')[1]}</fl:echo>
</project>
if you have further requirements -- you mentioned a "need to increment" -- you have to give more details.It's no problem to wrap it in a for loop with Flaka.

How to add top level element using Linq to XML

Assuming I have a xdocument called xd, with the following xml already created.
<Alert>
<Source>
<DetectTime>12:03:2010 12:22:21</DetectTime>
</Source>
</Alert>
How would I be able to add another Alert element, such that the xml becomes:
<Alert>
<Source>
<DetectTime>12:03:2010 12:22:21</DetectTime>
</Source>
</Alert>
<Alert>
</Alert>
Adding an additional elements seems to be fairly easy, but when adding in a top level element it excepts.
Your desired XML structure is invalid; you need a root element in order to add another "Alert" node. The following code shows how to add it when a root node exists:
var xdoc = XDocument.Parse(#"<root>
<Alert>
<Source>
<DetectTime>12:03:2010 12:22:21</DetectTime>
</Source>
</Alert>
</root>");
xdoc.Root.Add(new XElement("Alert"));
Console.WriteLine(xdoc);
The above code produces <Alert /> since no child nodes are added to it (this will change once you add to it). If you want the closing tag as you have shown you can use xdoc.Root.Add(new XElement("Alert", String.Empty)); instead.
To verify that your desired output has an invalid structure you can try parsing it using XDocument.Parse similar to what I've shown above.

Resources