Hi,

This is how we solved this problem:
On the Jenkins buildserver we added the following to our settings.xml

<profiles>
  <profile>
    <id>jenkins</id>
    <properties>
<port>600${EXECUTOR_NUMBER}</port> <!-- port could be for any plugin, so not really a good name -->
    </properties>
  </profile>
</profiles>

<activeProfiles>
  <activeProfile>jenkins</activeProfile>
</activeProfiles>

This assumes a maximum of 10 executors on the buildserver.
Now you don't have to specify the port on the commandline, it'll be picked up from these settings.

I'm not sure anymore if we had to expose these JENKINS variables and if it had to be prefixed with "env.", but this should be enough info to solve your problem.

Robert

Op Mon, 12 Aug 2013 10:44:00 +0200 schreef thermaleagle
<[email protected]>:

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.



--
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: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to