demokritos
demokritos

Reputation: 1446

Getting TFS Build Schedules

I am trying to write a query for all builds, but failed to understand the column [ScheduleTime] in the table [tbl_Schedule].

SELECT bd.DefinitionName 'Name', s.ScheduleTime 'ScheduleTime', s.ScheduleTime/1800 'Hour'
FROM [TFS_FTPDev].[dbo].[tbl_Schedule] s
inner join [TFS_FTPDev].[dbo].[tbl_BuildDefinition] bd on 
bd.[DefinitionId]=s.[DefinitionId]
where ContinuousIntegrationType in (8,16)
order by s.ScheduleTime asc

If I divide by 3600, I get a sensible data, but it is not valid for all my builds... i.e. Build1 and build2 are scheduled for 13:00 for some days....

name   ScheduleTime Hour
build1 43200    12
build2 43200    12
build3 68400    19
build4 77400    21.30
build5 79200    22
build6 82800    23
build7 84600    23.30
build8 84600    23.30
build9 84600    23.30

and the mapping is:

when 84600 then 23.30 
when 79200 then 22 
when 77400 then 21.30 
when 68400 then 19 
when 43200 then 12 

UPDATE: [Using TFS API]

And this is the API results for a manually triggered/scheduled build...

API results for a manually triggered/scheduled build

And this is the subset of results

Subset of Results from TFS API

Upvotes: 1

Views: 476

Answers (3)

Giulio Vian
Giulio Vian

Reputation: 8343

The documentation for ISchedule.StartTime Property says

Gets or sets the time as the number of seconds past midnight

So you should divide by 3600 to get the starting hour, the remainder divided by 60 is the starting minute within the hour. Am I missing anything?

Upvotes: 1

Just TFS
Just TFS

Reputation: 4787

I'm not really sure what you are asking but if you use 3,600 (60 seconds x 60 minutes) you get values as expected.

  • 00:00 = 3600
  • 00:30 = 5400
  • 04:00 = 14400
  • 05:30 = 19800
  • 23:00 = 82800

Your question regarding why some have schedules while being manual builds can be replicated by:

  • create a build definition
  • Schedule it
  • Clone the build definition
  • Rename it and before saving change the trigger type
  • Even though this build has never been scheduled it still contains a scheduled time

I would therefore suggest the builds that you are enquiring about have actually been cloned from another build and then the meta data changed, scheduled time seems not be cleared when a build is changed from scheduled to Non Scheduled. either that or at some point during their history they have had a scheduled time set, which has since been changed

Upvotes: 0

Ed Blankenship
Ed Blankenship

Reputation: 5223

Have you taken a look at the QueryBuilds method in the TFS Build API instead of reading from the database (which is unsupported)?

Upvotes: 1

Related Questions