I am trying to execute an Ant script through jenkins but it fails when it attempts to use webpack...
The ant script's execution task is the following:
<exec executable="webpack.cmd" failonerror="true">
<env key="PROD_ENV" value="true"/>
</exec>
where webpack.cmd has been installed as a global npm module. The module directory has been included in the Path variable and I have even made sure that Jenkins is actually able to see it by doing a trial run inside a Execute windows batch command build step. However when it attempts to execute it via Ant it fails. Could it be a problem with the Ant plugin and its version?
The error i'm getting is the following:
Execute failed: java.io.IOException: Cannot run program "webpack.cmd": CreateProcess error=2, The system cannot find the file specified
webpack.cmd needs to run in a command shell. Try...
<exec executable="cmd" failonerror="true">
<env key="PROD_ENV" value="true"/>
<arg value="/c"/>
<arg value="webpack.cmd"/>
</exec>
You may need to provide the full absolute path to webpack.cmd so cmd.exe can find it.
Related
As part of project, I prepared a Ant script which will download files from SVN and copy the files to remote server using scp.
But client asked me to copy only changed files from next deployment onwards in Jenkins instead of copying complete set of 20+ MB files.
got rsync command to do this but here the problem, how to send password from Ant
<exec executable="rsync" dir="/copy-files/js/" failonerror="true">
<arg value="-rcv"/>
<arg value="${username}#server:/media/js/"/>
</exec>
How to pass password from Jenkins, tried with RSYNC_PASSWORD and password-file options but not working.
You can pass values for environment variables by using nested env elements:
<exec executable="rsync" dir="/copy-files/js/" failonerror="true">
<arg value="-rcv"/>
<arg value="${username}#server:/media/js/"/>
<env key="RSYNC_PASSWORD" value="[your.password]" />
</exec>
I can run the following terminal command just fine:
security cms -D -i ../MyMobileProvision.mobileprovision > provision.plist
However, when I run it in Ant, from an ant script in the exact same directory, terminal claims the provisioning file doesn't exist and it creates an empty file for provision.plist, which screws up the next step in my process. The ant code looks like this:
<exec executable="security">
<arg line="cms -D -i ../MyMobileProvision.mobileprovision > provision.plist" />
</exec>
Am I missing something about how ant works? I'm no expert at build scripts but I can use ../ syntax to import properties files just fine, so I'm confused why a relative path isn't working for a terminal command that otherwise would work fine with it.
In your terminal command example, the snippet...
> provision.plist
...is interpreted by your shell as a redirect command.
The <exec> task of Ant doesn't use a shell to execute commands. Instead, the > provision.plist is passed unmodified to the security program.
To get what you want, use the output attribute of <exec>. output is the name of a file where <exec> will write the output:
<exec executable="security" output="provision.plist">
<arg value="cms" />
<arg value="-D" />
<arg value="-i" />
<arg value="../MyMobileProvision.mobileprovision" />
</exec>
In the above example, I've replaced the <arg line="..."> with several <arg value="..."> elements. The reasoning from the Ant documentation on Command-line Arguments:
It is highly recommended to avoid the line version when possible. Ant will try to split the command line in a way similar to what a (Unix) shell would do, but may create something that is very different from what you expect under some circumstances.
I got a simple ant target :
<target name="doxygen">
<exec executable="doxygen" dir="${basedir}/doxygen">
<arg value="Doxyfile" />
</exec>
</target>
I'm on Windows Seven.
When i try the same command line ( doxygen Doxyfile ) in the Windows console, it works perfectly. The doxygen executable can by found because i added the good path in my PATH environment variable.
But ANT juste can't find the doxygen executable and i get the following error :
build.xml:83: Execute failed: java.io.IOException: Cannot run program "doxygen.exe" : CreateProcess error=2
How can i make ANT to use the Windows PATH environment variable ?
I already tried the searchpath property, but i don't works.
You want to find where Doxygen is currently installed on your system. Then make a property with that value, so it can be overridden by people that installed doxygen somewhere else.
<property name="doxygen.path" location="C:\Program Files\Doxygen"/>
<target name="doxygen">
<exec executable="${doxygen.path}/doxygen" dir="${basedir}/doxygen">
<arg value="Doxyfile" />
</exec>
</target>
I try to start JBoss with ant.
When i execute this script :
<target name="start-jboss" >
<exec executable="${jboss.bin.dir}\run.bat" >
<arg line="--configuration=Myserver -b localhost" />
</exec>
</target>
JBoss is blocking at this step :
[exec] 15:52:55,373 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-localhost%2F127.0.0.1-8009
But when i run the run.bat it works... Its the same when i add spawn="true" in exec.
I think that the problem comes from eclipse...
Thanks
To run a batchfile use cmd as executable, something like :
<exec dir"yourworkingdir" executable="cmd" failonerror="true">
<arg line="/c ${jboss.bin.dir}\run.bat --configuration=Myserver -b localhost"/>
</exec>
if arg line=... doesn't work, use arg value=... for every parameter.
EDIT : if you have trouble using the batchfile, why not get rid of using that addtional batchfile and use the java task straightforward as explained here ?
I am facing a rather odd problem with our groovy build script. The whole project uses a helper groovy script that calls all other build scripts (maven and ant). One of the ant targets invoked by the groovy script calls, invokes through "exec" grails war:
<exec executable="cmd" dir="${parentDir}/${grails.appname}">
<arg value="/c"/>
<arg path="${env.GRAILS_HOME}/bin/grails.bat"/>
<arg value="war"/>
<arg value="${grails.appname}-${app.version}.war"/>
</exec>
The call of this block fails with:
[exec] Application is pre-Grails 0.5, please run: grails upgrade
Any suggestions how to go around this problem?
Thanks for your time.
I finally found the solution to the problem, I don't know if this is the best way but it fixed my problem. So in the same target as the "exec" block I added a new "exec" block to invoke the upgrade on the grails.bat. So far so good, calling this command without parameters will generate a confirmation question whether to proceed with the requested operation - in ant this will create an infinite loop. In order to avoid this I added the "-f" parameter. The whole exec block:
<exec executable="cmd" dir="${parentDir}/${grails.appname}">
<arg value="/c"/>
<arg path="${env.GRAILS_HOME}/bin/grails.bat"/>
<arg value="upgrade"/>
<arg value="-force"/>
</exec>
Hope this will help somebody.