It's all about the answers!

Ask a question

Build Forge: Start build on changed directory


Andy Jewell (24236374) | asked Aug 02 '13, 12:02 p.m.
 HI. . . Does anyone know a good approach for starting a build if files are added to a directory?  We have some business users that do not know (and do not want to know) anything about source code, etc.  So we put a little web page up that they can upload their files which we then want Build Forge to notice and start a build upon.

I couldn't find anything jumping out at me on the web.

The approaches that come to mind (keep in mind I'm a BF newb!) are:

  • Create a selector such that if files are found in the designated location then the server is available to run the build.  First, I'm not sure if this would work, second, it doesn't seem conceptually accurate.
  • Use a cron job on the target server and somehow (?) initiate the build via API or command line tool (I've not gotten into BF enough to know what command line tools it has available).  Though this seems workable, it also seems to contradict the whole point of an automation framework.  If I have to kick it from outside I may as well just kick the build process from outside.
That's about all I can think of.  What I'm hoping is that there is some sort of event-adapter that I don't know about that can initiate a build when a configured directory on the build agent changes.

Anyone have any ideas?

- Andy

Accepted answer


permanent link
Spencer Murata (2.3k115971) | answered Aug 02 '13, 12:16 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
 You could do a collector/selector combination to count the files in a directory, but that will not be very responsive.  The manifest refresh on the servers is on a 24 hour cycle by default.  I would lean toward writing an adaptor to do what you want.

Adaptor help:

Assuming that you move the files out of upload directory on the build, then you could set it up to do a 'ls | wc' or something along those line to find if the count is above zero.  If the count is zero, then the adaptor should fail.  Otherwise it would succeed, move the files to another staging area, and move onto the real build.

~Spencer

Andy Jewell selected this answer as the correct answer

Comments
Andy Jewell commented Aug 02 '13, 2:11 p.m.

Wow, that's quite an adapter language.  Ugh, guess I'd better roll my sleeves up.  Thanks, Spencer, appreciate the pointer! 

One other answer



permanent link
Robert haig (1.0k16) | answered Aug 07 '13, 4:52 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
 If you know what one of the files will be named, you should look at the .monitor command

The .monitor command causes the system to halt the project while it watches a file to see when the file size stops changing. When a step issues this command, the system checks the indicated file; it then rechecks the file every <interval> seconds. When the file size fails to change between two intervals, the system continues to the next step.

If you use the -c option, the system writes the contents of the monitored file out to the step log after it determines that it has stopped changing; then it continues on to the next step.

If the file does not exist, then the system does not wait but continues immediately after the first interval. Use the -w option to force the system to wait for the file to be created before starting the monitoring process.


you could also write a looping conditional step (might be easier to understand than the adaptor language) that called a library that checked the number of files in a directory, set an environment variable, then a conditional step that if the env var was set a certain way, chained the project you want to start.

Given your use case, I'd write a project that checked a directory and chained as above, and I would call it from a schedule every once in a while depending on your situation.

Comments
Andy Jewell commented Aug 08 '13, 12:04 p.m.

Thanks, that does sound like a viable alternative.  I'm actually looking at this from another angle, now, since the process that gets the file to the directory is also under my control.  It would be the cleanest approach to kick off the build at the same time as the file was dropped.  Do you know if Build Forge has a REST or other web service interface that would facilitate that? 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.