Sreedevi
Sreedevi

Reputation: 41

How to trigger a hudson job by another job which is in a different hudson

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

Upvotes: 4

Views: 5526

Answers (5)

girafi
girafi

Reputation: 130

I'm using wget to trigger the build:

wget --post-data 'it-just-need-to-be-a-POST-request' 
--auth-no-challenge --http-user=myuser --http-password=mypassword
http://jenkins.xx.xx/xxx/job/A/build?delay=0sec

There's other ways how you can trigger a build, see the REST and other APIs of jenkins. But this works great on unix.

Upvotes: 1

Kanso
Kanso

Reputation: 21

Personally, I find the easiest way to do this is to watch the build timestamp: PROJECT_NAME/lastSuccessfulBuild/buildTimestamp

Upvotes: 2

Jim
Jim

Reputation: 369

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.

Upvotes: 4

Christopher Orr
Christopher Orr

Reputation: 111555

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.

Upvotes: 6

morechilli
morechilli

Reputation: 9817

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.

Upvotes: 5

Related Questions