maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SARTAJ HUNDAL <vektor.kni...@gmail.com>
Subject Re: How to pass the contents of a file as the value of a command-line parameter when invoking a maven goal
Date Mon, 12 Aug 2013 23:27:27 GMT
On 13-08-12 02:44 AM, thermaleagle wrote:
> Hi,
> I need to pass the contents of a file as the value of a command-line
> parameter when invoking a maven goal.
>
> Why?
> The maven goal I am calling would trigger a server process on a certain
> port. This goal will be setup in a Jenkins build as a continuous integration
> test job. And there could be more than one such jenkins job. So I want to
> ensure that each server process starts on a different port.
> I have scanned for an available port in a "pre-build" step and have written
> the identified port to a file port.txt and have ensured that it is available
> in the Jenkins job's workspace before the Maven build is triggered.
>
> What I want to do now is specify a maven goal like below within the Jenkins
> job I'm writing:
> integration-test clean install -Dport=$(<port.txt)
>
> Assuming that port.txt only contains a string like "6001", the above command
> should (at runtime) become:
> integration-test clean install -Dport=6001
>
> And when the job runs, a client should connect a url constructed as below:
> http://localhost:6001/web_service/myapp
>
> Note that the port in the above URL is taken from incoming command-line
> parameter 'port'.
>
> However, when I configured this into Jenkins, the job failed with the
> stacktrace containg the below:
> Caused by: java.net.URISyntaxException: Illegal character in authority at
> index 7: http://localhost:$(<port.txt)/web_service/myapp
>
> I am executing the job on Linux and have verified that $(<..) is supported
> on the version of the shell that I am running. So I think replacing
> $(<port.txt) with `cat port.txt` is not the answer that might help me.
> The problem seems to be lying in the way I'm using the maven command-line.
> Looks like the shell is passing everything it sees on the command-line to
> Maven which has no clue how to handle it!
>
> Hope I made the problem clear. All help is appreciated.
>
> a. Read each line of port.txt and store as ${line}

>
> --
> View this message in context: http://maven.40175.n5.nabble.com/How-to-pass-the-contents-of-a-file-as-the-value-of-a-command-line-parameter-when-invoking-a-maven-gol-tp5767482.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
I. Your error is with respect to the URI (uniform resource identifier) 
syntax being presented to Java.net.
ii. Java objects are not inherited in XML, but can be passed in with a 
pre-processing step.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message