How do I trigger another job from hudson as a pre-

2019-01-08 16:13发布

问题:

How do I trigger another job from hudson as a pre-build step?

回答1:

There is a Parameterized Trigger Plugin, which enables "Trigger/call builds on other projects" in "Add build step" menu.



回答2:

You can use the plugin at http://wiki.jenkins-ci.org/display/JENKINS/Join+Plugin

Basically you create 3 jobs:

A = your prebuild ste

B = your main job

C = your trigger.

You 'build' C. It calls A, and once A is successful, it calls B. The plugin page gives you more information. The good thing about this plugin is that you can have any number of pre-build jobs.

We actually have a set of 5 pre-build jobs before our main is run.

================================================

If you don't want to try that:

If you are using Linux, you can do the following from within your "shell" script:

wget http://yourserver/hudson/job/MyJob/build?delay=0sec

This will trigger the job. The bad part about this is that it will not wait for the job to finish.



回答3:

I have the same issue and I found a way to do:

I am using jenkins version jenkins-1.452-1.1.

Say I have job A and B, and Job A is depending on job B. When building job B, I want A triggered automatically, and B is blocked until A build successfully.

When define build configuration in build section, I add 'trigger build on other projects'. then fill the form.



回答4:

Actually I know how to answer to your question: This is the plug-in that you need:

PreBuild

It is not widely famous, but it does what you want.

It basically runs a Build before your chosen one. For example: You want A to run before B. You click on "run B" it will execute A before running B.

Pro: -> Very versatile -> Easy to use

Cons: -> No support / Option in case the pre-build fails (e.g. do not build if pre-build fails) -> The development seems not being that active at all.

Here you can see how it looks like

EDIT

This answer is back from '12, I know you are down-voting it, but back then this was a reliable solution, now I am sure there are other plug-ins that do the job.