I have created a little tool for myself that I have call Altiris Job Builder, it retreives the Jobs from the Altiris database and shows them in a Treeview.

Then I can assemble a Master Build Job by dragging the needed Jobs to another Treeview on the right. Since it’s just for me it doesn’t have a fancy gui:

JobBuilder2

So why did I write it? Well I have divided my Jobs into Prerequisites and Packages, for instance IIS and Terminal Server and Java are prereqisuites for Citrix. But many prereqisuites are required for one or more other packages, eg Java is also used for certain applications.I don’t want to make copies of Jobs since that means I have to change it in multiple places. For instance say we upgrade to a new Java version we would need to update multiple jobs instead of one (which is very likely to wrong ).

So the idea behind this master build is to create a Master Build Job that fires off all the needed jobs for a certain package. I use AxSched in an integrated script job for that. So my tool generates something like this:

But lazy as I am I don’t want to manually copy/paste this into a job but rather insert it directly into the database. If we look at the eXpress database scheme we can see that there is an event table (a Job is really an Event in Altiris):

EventTable

Only the event_id field is mandatory and it’s also the Primary Key of the table. However the event_id is not auto generated so if we insert a new record how do we now the right value for event_id?

One approach could be to read the highest value and increment that by 1 but that seems dangerous for various reasons. So I figured there was probably a Stored Procedure for adding a new Job/Event.

In the SQL Server Management Studio we can find Stored Procedures under the Programmability Node of the Database:

StoredProcedures

If you look into the available Stored Procedures you will see that there are del_xxx and ins_xxx events. We need the ins_event Stored Procedure:

InsEvent

In Delphi we can use the TADOCommand object to call a Stored Procedure:

The ins_event Stored Procedure returns the new JobId in the @RETURN_VALUE parameter. This is very convenient because we need the JobId to add tasks to the new Job, in this case a script task.

But enough talk for today, I hope you find the subject interesting and I would be very interested to hear about other solutions or concepts for a Master Build Job.