My project uses ANT build system. Currently, I am giving build via shell command for my project. Say when I give "ant dev deploy" from cmd prompt the build starts and in between it stops for confirmation from user. The runtime value "dev", which is passed as a confirmation variable, then the build continues based on the value passed. This is how it should be and it was working correctly till now.
Currently I am automating this build via hudson. I have given the value "ant dev deploy" in the targets of the Build properties in hudson. But, now I don't know how to configure to get the value "dev" in between the build progress. During my trial, I was getting error for that.
Is there anyway I can pass the value on runtime?
You cannot pass a value to Hudson in the middle of the build. You need to supply that at the time of triggering the build. Hudson is not interactive, so anything in your current process that requires user prompting half way through needs to be redesigned.
All your user prompting needs to be done through build parameters at the beginning of the build. In the job configuration, check mark This build is parameterized. If you want to restrict the possible values, a "Choice" parameter is best. Give it a name, for example CHOICE1
, give it a list of possible choices. When the build is manually triggered, the user could choose one of the choices from a drop-down, and then start the build. Note that this will not work with builds that are automatically triggered.
Next, you need to pass this value to your ANT script. In your Invoke Ant build step, click "Advanced" button, and under "Properties" you can pass variables to your ANT script:
antScriptVar=$CHOICE1
Above, $CHOICE1
is the reference to the Hudson build parameter, it will contain the value the user selected from the drop-down when starting the build. The antScriptVar
is your variable in ANT script that will have this value. You can define the empty variable in ANT script with
<property name="antScriptVar" value="" />
When Hudson triggers the ANT script, it will populate this variable with the build variable. From then onwards, use it like you would any other variable in ANT