I automated the build, create and deployment process of bar files on my local system. Now I want to store generated Artifacts into Google Cloud Storage(buckets) using AntScripts.
Here my doubt is, Can we write Ant scripts for Uploading Artifacts to goggle storage buckets? if we can, what is the list of dependency JARs we need to add into ANT library installation path?
so, Can anyone give a suggestions on this or any reference links would be fine?
Yes, we can write Ant script for Uploading Artifacts to goggle storage buckets
Below is the sample code snippet
<target name="uploadArtifact">
<echo message=" uploading artifacts />
<exec executable="/var/lib/jenkins/google-cloud-sdk/bin/gsutil">
<arg value="cp"/>
<arg value="source-path"/>
<arg value="destination-path"/>
</exec>
</target>
Related
I am using ANT to build artifacts(finally all artifacts will be zipped in one zip file) and jenkins plugin 'Nexus Artifact Uploader' to upload artifact to nexus repository.
I want to download the artifact(zip file) from nexus repository using ANT OR jenkins plugin only. I am not supposed to use maven for this task. Also, unix commands like 'wget' or 'curl' are not allowed in my deployment environment. It fails with permission denied error. So, I want solution using either ANT or jenkins plugin only.
Can anyone please help.
You can use below ant project snippet to download artifacts from nexus
<project name="testdown" default="dependencies" basedir=".">
<target name="dependencies">
<mkdir dir="libraries" />
<get src="http://10.135.155.72:8081/repository/maven-central/log4j/log4j/1.2.9/log4j-1.2.9.jar" dest="liblibraries/log4j-1.2.9.jar" usetimestamp="true" />
</target>
</project>
Running in to ussue using FTP task from Apache Ant. Finding that an empty directory is not being created in the target location. Is there way to force the transfer to create the directory? this is representative of the task specified in my ant build script. the first three substitutions are obvious the 4th is the source directory and the 5th is the target directory.
<ftp action="get"
server="${Server}"
userid="${User}"
password="${Password}"
passive="true"
remotedir="${DependenciesDirectory}">
<fileset dir="${bldSrvDependenciesDirectory}">
<include name="**/**" />
</fileset>
</ftp>
This is a known limitation of ant ftp and scp task. The simple workaround is to make sure every directory contains at least some dummy placeholder file.
We have an automated build process that uses Nant scripts, and we just inherited a Java project that has an existing, working Ant script. I have searched all over and it seems most people use a batch file to call Ant scripts from Nant. This seems a little hacky to me. Is there a way to call Ant scripts directly from Nant in task format?
This similar question addresses it with a batch file but I want to do it without.
<!-- calling the Ant build Process-->
<target name="AntBuildProcess" description="Created to call the Ant build during this NAnt build process" >
<echo message="Starting the Ant Build Process..." />
<exec program="ant" commandline='-buildfile YourAntBuild.xml' failonerror="true"/>
</target>
Then during your Build process, you just call this target at the point you need it to be built. <call target="AntBuildProcess" />
Ant is a batch file. Take a look, and you'll see a file called ant.bat in the %ANT_HOME%\bin directory.
Ant is actually a Java program, so you could launch it from the java command by running the class org.apache.tools.ant.launch.Launcher which is basically what the ant.bat file is doing.
However, why reinvent the wheel? The ant.bat runs the Java command the right way, gives you options to change the way it's executed, and makes sure everything is setup correctly.
Addendum
I see, Nant, unlike Ant, will always call cmd.exe and use suffixes and %PATHEXEC% to figure out if something is a batch script or other type of script. Thus, if you want to run Ant using Ant as a batch script via <exec/> you would do this:
<exec executable="cmd.exe"
dir="${working.dir}">
<arg value="/c"/>
<arg value="ant.bat"/>
</exec>
However, in Nant you can simply do it this way:
<exec program="ant"
workingdir=${working.dir}"/>
i want to deploy a java web application.but with some changes i need to use the same application for trail also. the difference is an additional package.by using Ant or some other tools, is it possible?i need to deploy the applications as two war file.sorry for my english
This should be possible using Ant. You can create two separate targets, one for each war, and then run both of them in your build.
<project name="Proj" default="package" basedir=".">
<target name="package" depends="war1,"war2" />
<target name="war1">
... build the first WAR
</target>
<target name="war2">
... build the second WAR
</target>
</project>
If you find the targets are repetitive you can break common parts out into smaller targets or you can use macrodef to create macro let's you run similar targets with different parameters.
I've been searching for a possibility to generate ANT targets from top-level macro.
Details:
We have heterogenic build system. ANT+IVY is used as top-level (inherited solutin, can't be changed). Some projects are built via MSBuild, called from ANT via exec task. For each of these projects, there's at least two distinct calls to msbuild (wrapped with macro for brevity), one in "build" target, and one in "clean". Two of them are different only by "target" parameter. So I was guessing, if there's possibility for something like this:
Extension nodes:
<extensionpoint name="build-ext-point" />
<extensionpoint name="clean-ext-point" />
<target name="build" depends="build-ext-point" />
<target name="clean" depends="clean-ext-point" />
My magic macro:
<macrodef name="msbuild-proj" />
<attribute name="project" />
<sequential>
<target name="#{project}-build" >
<msbuild project="#{project}" target="Build" />
</target>
<target name="#{project}-clean" >
<msbuild project="#{project}" target="Clean" />
</target>
</sequential>
</macrodef>
How it would be used:
<msbuild-proj project="CPP-proj" />
Thanks!
P.S: Yeah I know that I can define those build and clean overridden, or via ext point, or whatever. The question is actually whether I can remove some code duplication.
UPD: I'd answer this by myself. At the point, there's no such possibility. Mainly, because Target class is a task container, but not a task. So, it cannot be placed into container. So I guess I'll write some kind of extensible task.
ANT has a couple of mechanisms for building modular builds.
First of all I think your main question was on how to build "extension points" to your build? The following ANT tasks are designed to import common build logic from another build file:
import
include
Since you're already planning to extend your build using macrodefs, I'd recommend packaging these as a reusable ANTlib. The ANTlib can live within your project, but it's really designed to be packaged within a jarfile which another build can pickup, for example by installing it in the standard ANT lib directory:
$ANT_HOME/lib
$HOME/.ant/lib
Finally, if you're already using ivy and you package your taskdefs as ANT libs, you could version your build logic by installing it in a Maven repository manager like Nexus. This addresses one of the key problems with large ANT builds. Over time they become so big it's impossible to change the common logic without impacting older builds (Demonstrating that the builds are not properly isolated from each other).
Actually done this.
Does its job, although some caveats are present.
For those interested: https://bitbucket.org/targetsan/ant-events