Jenkins - setting up a trigger on another project

How can I call a parameterized assembly only if the parent finished successfully AND had changes (changes were pushed to scm)?

Here is the scenario: I have 3 assemblies: A, B and C. B will be built if called by A or has changes. C should only be built if B finished successfully and if B was built due to scm and NOT changes because it was called by A

thank

+3


source to share


1 answer


Add to A:

Actions after assemblingTrigger with parameterization based on other projects:

  • Build projects: B

  • Start on build: complete (always trigger)
  • Add SettingsPre-defined parameters: A_HAS_BEEN_BUILT=YES

Add to B:

Metadata → [✔] This assembly is parameterized → Add Valueline option:

  • Name: A_HAS_BEEN_BUILT

  • Default value: NO



Actions after assemblingTrigger with parameterization based on other projects:

  • Build projects: C

  • Build Trigger: Stable [default anyway]
  • Add SettingsPre-defined parameters: A_HAS_BEEN_BUILT=${A_HAS_BEEN_BUILT}

Add to C:

Metadata → [✔] This assembly parametrizovana_ → Add Valueline option:

  • Name: A_HAS_BEEN_BUILT

  • Default value: NO



CreateAdd build stepConditional step (single):

  • Run: Not
  • !: Regular expression
    • Expression: ^YES$

    • Label: ${ENV,var="A_HAS_BEEN_BUILT"}

  • Builder: ... according to your needs ...


See Parameterized Build , Parameterized Trigger Plugin, and Run Conditions Plugin.

UPDATE 1

The above settings cause the following:

  • A builds → B builds → B is stable; C starts but doesn't create
  • B SCM polls → SCM changes → B builds → B is stable; C builds

As per the discussion, the following is assumed:

  • A builds -> B builds
  • B SCM polls → SCM changes → B builds → B is stable; C builds

UPDATE 2

To prevent C from running in 1 .:

  • Create a bubbling project in B that polls the SCM and B triggers

  • Configure the following in B:

    Source Code Management → ◉ No

    Build Triggers

    • [] SCM Poll


    BuildAdd build stepConditional step (single):

    • Run: execute shell command / execute windows
      • Command: ... SCM checkout commands; set the output status / ERRORLEVEL more than 0 in case of no SCM changes ...
    • Builder: Trigger / call builds on other projects
      • Build triggers
        • Build projects: C

+9


source







All Articles