2

There is always an extra build with triggered by "promote build plugin" on jenkins, which I dont know why...

Here is the whole pipeline:

  1. dev commits "feature_branch" to github
  2. jenkins triggers a build on "feature_branch" to run all unit tests

on build-job:

  • if the branch passed the test, it should go to "code review" (I use promote_build_plugin here, manually promote after code view),
  • I use "Trigger/call builds on other projects" as the action to trigger "deploy-job" to build only if it passes code review.

on deploy-job:
I can see a new build is triggered and that feature_branch is merged, but there is always another build take place with "no changes; Legacy code started this job. No cause information is available"

I googled a whole afternoon trying to solve this, any help?

Slav
  • 27,057
  • 11
  • 80
  • 104
Hao Huang
  • 53
  • 4

1 Answers1

0

You probably have a post-commit hook that is triggering the same job through a URL or jenkins-cli

Edit after OP comments:

But I start to wonder on the deploy-job, I didnt configure "Build when a change is pushed to Github", instead, I use "Build when another project is promoted", so I think even github hook is triggered, it wont end up with an extra build?

Well, there is your problem ^^. The "Trigger/Call builds" mechanism is completely separate from the "Build when another project is promoted".

  • The former allows to trigger a new build from a buildstep or a promotion (tied to that specific promotion).
  • The latter will trigger a build on any promotion of the configured job. It is the inverse of "Build other projects" post-build configuration.

Furthermore, build triggers are not AND'ed, they are OR'ed. Build when this or that or that trigger happens. Remove the "Build when another project is promoted" from configuration to git rid of extra builds.

Now, if you want to prevent builds from being triggered by SCM commit hooks, you need to make sure there is no SCM polling configured on the job. Alternatively different SCM plugins have their own options (I know SVN SCM plugin allows to "ignore post-commit hooks"; don't know about git SCM plugin)

Slav
  • 27,057
  • 11
  • 80
  • 104
  • I think I know the reason thx to your reply. It's maybe due to the second(**deploy-job**), which is only for merge the feature branch to remote master. It gets the ${GIT_BRANCH} from previous **build-job** and "git publisher" it. I am using github webhook service now and checked there indeed are 2 pushes. But I start to wonder on the **deploy-job**, I didnt configure "Build when a change is pushed to Github", instead, I use "Build when another project is promoted", so I think even github hook is triggered, it wont end up with an extra build? – Hao Huang Apr 24 '14 at 20:45
  • Anyhow, is there a way to configure jenkins do not start builds when triggered by certain circumstances? – Hao Huang Apr 24 '14 at 21:05
  • Well, there is your problem :) Updated answer. – Slav Apr 25 '14 at 13:27