views:

648

answers:

3

I have job A in Hudson A and Job B in Hudson B. I want to trigger job A by Job B.

+3  A: 

I haven't used Hudson but I would guess your simplest approach would be to use the URL trigger:

http://wiki.hudson-ci.org/display/HUDSON/URL+Change+Trigger

I think there is a latest build url that could be used for this.

morechilli
I think the last successful URL http://SERVER:PORT/job/JOBNAME/lastSuccessfulBuild/ should work with the URL change trigger, if you want to trigger job B only if job A is successful. If job B should always be triggered, try the last build URLhttp://SERVER:PORT/job/JOBNAME/lastBuild/
Peter Schuetze
+3  A: 

In your job B configuration, check the Trigger builds remotely (e.g., from scripts) checkbox and provide a token.

The help text there shows you the URL you can call to trigger a build from remote scripts (e.g. from a shell script in Hudson job A).

However, that would trigger job B no matter what the result of job A is.
Morechilli's answer is probably the best solution.

Christopher
When one step of a job fails, Hudson does not execute the following steps. So when your call of the remote job is the last step it will only execute if the previous step was successful.
Peter Schuetze
A: 

In the latest versions of Hudson, the lastSuccessfultBuild/ HTML page will contain the elapased time since it was built, which will be different for each call. This causes the URL Change Trigger to spin.

One fix is to use the xml, json, or python APIs to request only a subset of the information. Using the 'tree' request parameter, the following URL will return an XML document containing only the build number of the last successful build.

http://SERVER:PORT/job/JOBNAME/lastSuccessfulBuild/api/xml?tree=number

Using this URL restored the behavior I expected from the URL Change Trigger.

Jim