schedule ant task - ant

Is it possible "and how if you know", to schedule the execution of an ant task?
For example, i want my build.xml to be executed every 5 hours or every day at a certain time?
I have been looking around but no solution found
Thank you

For very simple requirements, I'd echo the use of cron.
If the reason for running ANT is to periodically perform a master build of your project's code, then you're effectively following a practice called "Continuous Integration". In that case I'd highly recommend running a continuous integration server, such as Jenkins.
Jenkins is a very useful piece of software, easy to install and can become your automation framework for more than just building your code.

Just use cron and call ant.sh from it.

If you are working on a windows environment, you can use the "task scheduler" and set the interval. If you are working in unix/linux, you may use cron for scheduling your job.

Related

How to schedule specific test in jenkins?

I've been looking for an answer to this question for a long time.
I have a big project with a lot of tests in jenkins.
I want that some of the tests run every time someone does "push".
and all the tests run every night.
How can I do this?
with the "Build periodically" I build all the tests with schedule and I dont found thet I can build specific tests.
Thank!
EDIT:
I run the tests with gradle, this is the configuratuin:
you can use the BUILD_CAUSE variable
on nightly trigger TIMERTRIGGER=true , after every push the value will be SCMTRIGGER
after that you can set a parameter and run the tests using it.

Jenkins Build Periodically - Once

I am trying to schedule a Jenkins Deployment task to run only once.
Why? So no one has to log in remotely to do after hours deployments (No Fun!)
So my question is: Is there a way to specify year within jenkins' cron syntax?
More info:
Under Build Triggers -> Build Periodically
If I schedule a build for today(Thursday, June 10th) at 10:52 AM
The cron syntax would be 52 10 10 6 2
However, the next June 10th will occur in the year 2025, so technically, the build will still be scheduled for 11 years from now, unless I manually remove the schedule.
This is not a huge problem, it just doesn't make sense to me someone hasn't come up with a solution for it yet.
I am not looking for hacks, scheduled tasks, or scripting... All of that would be more work then just manually removing the schedule. I would like to keep this completely inside of jenkins
If this is truly impossible, I will consider writing a plugin for this specific use-case.
Well after much digging I finally found it:
https://wiki.jenkins-ci.org/display/JENKINS/Schedule+Build+Plugin
It adds ^^ the schedule build button to all projects which provides a nice UI to set a date and time, instead of dealing with that ridiculous cron syntax.
Jenkins' Modo should be "There's a plugin for that"

continuous integration for many languages

I want to setup a continous integration system that upon a commit or similar trigger should:
run tests on a fortran/C/C++ code, if needed.
compile that code using cmake.
run tests on a rails app.
compile the rails ap.
restart the server.
I'm looking at Jenkins. Is it the best choice for this kind of work? Also, what's the difference between using a bash script that makes all that (if possible) and using jenkins? I'm asking not because I'm thinking about using a script, but to better understand jenkins.
It sounds like Jenkins would certainly be a reasonable choice for this. Apart from the ability to run arbitrary scripts as build steps, there's also a large number of plugins, which provide better integration with cmake for example.
Even if you're using a single bash script to do all of this, using Jenkins on top of it would still have a number of advantages. You get a web interface, email notifications and build history for free, with all that this entails. By integrating your tests "properly" with Jenkins, you can also get things like graphs that show how many tests succeeded/failed over time.
I am using Jenkins for java projects and have to say it is easy to configure. I used to add lots of plugins for better configuration of build steps, but tend to go back to using scripting languages for build and deploy steps because of two main reasons. If I have a build script, it's easier to configure the same job on a different Jenkins server or run the script manually if need be and the build configuration is not so cluttered (I still have one maven job with more than 50 post build steps). The second reason is, that it is easier to version the scripts in SVN, compared to having the build config in SVN.
So to answer your questions. I don't know if it is the 'best' tool, but it is good enough for me. Regarding scripting: use each tool for what it is build for. Jenkins a glorified cron deamon with great options when it comes to displaying analysis. The learning curve for people to use it is minimal (i.e. starting a job, seeing whether it failed.) Configuring Jenkins needs a little bit more learning, but it's very easy to set up simple jobs and go then to the more complicated tasks.
For the first four activities Jenkins will do the job and is rather the best choice nowadays, but for things like restarting the server (which is actually "remote execution"), better have a look at:
http://saltstack.com/
or:
https://wiki.opscode.com/display/chef/Home
http://cfengine.com/
http://puppetlabs.com/
http://cfengine.com/
Libraries like Fabric(Python) or Capistrano(Ruby) might be useful too.

Ant task to configure RabbitMQ

I am setting up my local build using Ant and have decided to use RabbitMQ. I would like to have any Ant task that I can use to configure my local installation for setting things up (stop, start, create queues etc..) and tearing them down as part of my test suite.
Has anyone come across anything like this?
I described a scenario in this question there the op was looking for a way to declare queues and bindings without the overhead of doing it at runtime.
In my solution I use a console utility to perform the queue declarations and have this called from a build step in my build server when running builds and tests.
During the normal course of coding and integration testing from the IDE, I simply make sure that I have used the utility fairly recently to make sure the queues have been established as per the current XML definitions. My test setups ensure that the queues themselves are empty before running.
Hope this helps.
Steve
Ant is a build tool. While running your automated tests is generally part of a build process, the setup of your queues are part of your specification's context and should be included in your tests. If you truly have a need to configure your exchanges and queues once before all test runs, many frameworks provide a facility to do this.

Scheduling msbuild task build Nightly

I am using MSBuild for building our test project from command prompt which inturn uses nunit and gives the results. I want to schedule it nightly so that it automatically runs the msbuild and get the results. Is there any way I can do that?
I would recommend using a Continuous integration server for this. You can set up your continuous integration server to schedule builds and a number of other tasks. Personally, I use Team City from Jetbrains, but there are other options available, such as Cruise Control.net and Hudson.
What exactly do you want to do with the results? If you just need to run your build script, a simple scheduled task should do it.
The way my company solved the problem was to use Powershell. We have a scheduled task that executes a powershell script that completely automates the process using MSBuild and devenv.exe.
We've been able to do away with the expense of many other continuous integration tools with this process. We have even connected it to our svn server so that it can checkout the latest revision, build it, send out an email if there was a build error and send the output of the screen as a result log.
I realize this might not be simple answer you're looking for, but Powershell was really easy for me to learn, exceedingly customizable, and very powerful. I had doubts when my Director said we were moving this way, but it's been a delight.

Resources