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
source to share
Add to A:
Actions after assembling → Trigger with parameterization based on other projects:
- Build projects:
B
- Start on build: complete (always trigger)
- Add Settings → Pre-defined parameters:
A_HAS_BEEN_BUILT=YES
Add to B:
Metadata → [✔] This assembly is parameterized → Add Value → line option:
- Name:
A_HAS_BEEN_BUILT
- Default value:
NO
Actions after assembling → Trigger with parameterization based on other projects:
- Build projects:
C
- Build Trigger: Stable [default anyway]
- Add Settings → Pre-defined parameters:
A_HAS_BEEN_BUILT=${A_HAS_BEEN_BUILT}
Add to C:
Metadata → [✔] This assembly parametrizovana_ → Add Value → line option:
- Name:
A_HAS_BEEN_BUILT
- Default value:
NO
Create → Add build step → Conditional step (single):
- Run: Not
- !: Regular expression
- Expression:
^YES$
- Label:
${ENV,var="A_HAS_BEEN_BUILT"}
- Expression:
- 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
Build → Add build step → Conditional 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
- Build projects:
- Build triggers
source to share