Good morning,
I am trying to call the create-job task of jenkins-cli right from ant. My problem now is, that ant won't let me use the "<" char.
Here is what I try to do:
jenkins-cli -s http://localhost:8080/ create-job < path/to/build.xml Dummy
Is there any way to do this?
Thanks in advance!
Ant buildfiles are XML, so you will need to use either an entity or escape sequence. The entity you need is <
Here's the other predefined XML entities.
Related
I have the following requirement.
from Ant xmlproperty task. What happens when there is more than one tag with the same name?
it's clear how to repeat for each file.
My requirement is to iterate for each file and I would like to get the value of 'machine' element for corresponding file
eg:
<echo>${PREFIX.main.tagList.tag.file[file1]}</echo> // should return machine1
<echo>${PREFIX.main.tagList.tag.file[file2]}</echo> // should return machine2
An example would help, but I think I discovered this limitation in the xmlproperty task before. For performing complex processing of external files I would use an embedded groovy task, which just loves XML :-)
You haven't specified a sample input, so here's a similar example:
Parse HTML using with an Ant Script
Is it possible to send one property file and a separate value as two different parameters to an Ant script ?
E.g. build.xml propertyfile=propfile -Dname1=value1
RTFM ;-) means see Ant manual running Apache Ant, f.e.
ant -f whatever.xml -propertyfile=/var/usr/foobar.properties -Dfoo=bar
multiple -Dkey=value or -propertyfile=path/to/propertyfile are possible
I have an ant build which contains tasks of format
build
build.foo.bar
So to add dependencies in gradle the first one is easy
build.dependsOn(...)
But the second one is interpreted as method nesting. I suspect there's a standard groovy way to do this but I haven't cracked it.
How do I reference an ant task containing periods in an build.gradle file?
project.tasks['build.foo.bar'].dependsOn(...)
should do the trick.
See Project.tasks, which returns a TaskContainer (extending TaskCollection), and TaskCollection.getAt() which, as its doc says, can be called using the [] operator.
I am reading a file in ant and loading the properties through loadproperties. I am interested in using the value of a specific property, whose name is not known. I know that it follows a pattern because that is how I load the property.
I can echoproperties and see that it is being loaded.
But I dont know how to access its value, given that its name is actually a pattern rather that hardcoded.
How can I access this property's value to do some processing.
I hope this is clear. Please ask if I need to clarify some more.
Take a look at ant-contrib package. Its propertycopy task will do what you need. If you need to resolve an arbitrary number of properties following an established pattern, you would use ant-contrib's propertycopy in conjunction with ant-contribs "for" task.
http://ant-contrib.sourceforge.net/tasks/tasks/index.html
You should use Ant's script task.
I suggest using the beanshell script since it is pure java.
For example, to print all properties for your project, use the following:
<target name="echoprops">
<script language="beanshell">
System.out.println("All Properties: " + project.getProperties().keySet());
</script>
</target>
It should be easy to modify the above script to get the property you want.
To use this task, you will need to run the following in $ANT_HOME first:
ant -f fetch.xml script -Ddest=user
That will download all required optional jars to ~/.ant/lib .
I was trying
Ant.echo("hello gant")
but I am getting this error message:
No such property: Ant for class: build
Any help would be highly appreciated.
In groovy you first need to create an instance of the AntBuilder class. The following code works:
def ant = new AntBuilder()
ant.echo("Hello world")
gant is also having "ant" injected itself
Actually in grails ant is avaiale by default.
ant.echo("hello gant")
You just need to use lower-case "a" in "ant" and run it. This should work fine.
The short answer to this question is just change Ant.echo to ant.echo or just omit "ant." and "echo" directly. It will call the ant.echo.
Another case will often cause this issue is when we define the property. Do not use property name like "ant.lib.path", "xx.xx.xx", it's not working in gant, gant will treat "lib" is the property of "ant" and "path" is property of "lib" , which is not correct, use "antLibPath" form instead.