I have an Ant task which runs if the lock file is not existing.
But if the build fails, then the lock file is not deleted at the end of the task and subsequently the task is not invoked from my scheduled jobs.
Is there anyway to handle such that even if build fails, I should be able to call my cleanUp task to delete the lock files?
Look at this: Testing and exception handling with Ant
There is macrodef with trycatch
This sounds to me like something that should be cleaned up at the beginning of any build.
Do you have an init task or some task on which all other tasks depend? I would just put the deletion of that file in there so that it always gets deleted even if a previous build failed.
However, it's a confusing requirement. It doesn't sound very idiomatic. Ordinarily, task execution is controlled through dependency and conditional properties. See the relevant section of the targets section of the manual for more details about if and unless. Creating a file is an expensive way to get the functionality already present in ant's core.
Related
We're using TFS-Online to One-Click-Deploy our Software.
From time to time it happens, that we need to use some special scripts, we store in a folder. This basically means, most of the time said folder stays empty.
If i now go and trigger a build, i have there followings tasks
Now the question:
Is there any way to suppress these two tasks if the folder to be zipped/deleted is empty?
The tasks are the built in ones.
Note: This is NO on-premise TFS
You could specify conditions for running a task in VSTS. Express the condition as a nested set of functions. The agent evaluates the innermost function and works its way out. The final result is a boolean value that determines if the task is run or not.
In your case, a solution should be:
Add a powershell task prior to the Archive Files task.
Use the powershell task to judge the folder is empty or not.
If the folder is empty then fail the powershell task.(Remember to check Continue on error or always run option)
Add a condition for both Archive File and Delete File task such as Only when all previous tasks have succeeded
After this, those two task will not run when the special folder is empty during the build pipeline.
More details please refer this thread Specify conditions for running a task.
How to execute Ant task on every document save in Intellij IDEA?
If you right-click on some task you can see Execute on -> After Compilation,
but I want to execute my task after each document save, how can I do it?
It's not possible and for a good reason. IDEA saves files automatically on many occasions and it would make your machine unusable.
I would like to make ANT process wait for another build or task to finish.
The situation is: I execute a few ANT builds simultaneously. In these builds there are tasks to test the apps. Unfortunately, only one flexunit task can be run at the same time, because it uses net socket to communicate with the AIR app.
The build process should wait for the end of the tasks from other build processes before starting its task.
How to achieve that?
Thank you for any hints,
Rafal
Use the <waitfor> task with your choice of synchronization.
I always use an "IGotTheResourceSoYouCantHaveIt" file that gets created after <waitfor> and deleted when I'm done with it.
Details:
delete the file in some higher-level "clean" so that if a build aborts it gets deleted eventually.
there's a small race condition between the <waitfor> and creating the file. In my use, it's not worth worrying about.
Hi I'm using TFS2010 to build a (master) project which itself sequentially calls two MSBuild tasks to build other (child) projects. The first child project uses a custom task which utilizes TFS API (to read information about build configurations). If the first child project executes this custom task (this task always executes successfully), the second call to MSBuild task (in a master project) always fails silently. In the log file I just get the following:
Task "MSBuild"
Global Properties:
<Some custom properties here>
Build FAILED.
0 Warning(s)
0 Error(s)
If that custom task is not executed everything builds fine. Both projects use other custom tasks (MSBuild.ExtensionPack and a couple of those written by me) and none of them makes the build fail.
Is there any way to troubleshoot the issue and to find out what am I doing wrong?
Seems that applying [LoadInSeparateAppDomain] attribute to the task class (I also applied [Serializable] and derived the task class from AppDomainIsolatedTask) solves the issue. Still I wonder how to troubleshoot such stuff.
I have many targets in my build.xml for Ant. Generally I am running two via a shell script, one to construct the application and one for cleaning up. The shell script checks the exit status of the construction to see if it should clean up or leave the clutter behind so I can determine what went wrong and fix it.
So went all is going well, the majority of the time, Ant is executed once for construction and once for clean up. This results in my build.number being incremented for each execution. So in steady state, my build.number increments by 2.
How can a tell Ant to not increment the build.number? I would do this for clean up as I haven't built anything.
I know the obvious answer of creating a separate script for clean up only, but I'd rather keep the entire build.xml in one file.
Why not define one target (the complete) build as being dependent on a compilation target and a cleanup target ? That way Ant only has to execute once, and if it bails out it won't execute the cleanup task.