Problem
Re-running a finished build reuses the snapshot dependency builds from the original run instead of building them again. This happens even when the snapshot dependency has Do not run new build if there is a suitable one cleared, which does produce a fresh dependency build when the same configuration is triggered normally.
Cause
Normal triggering evaluates each snapshot dependency against the suitable builds criteria, so clearing Do not run new build if there is a suitable one forces a new dependency build.
Re-running a build goes through build promotion instead. The Run custom build dialog pre-fills its Dependencies tab with the chain builds that already exist, because re-running is treated as running one build again rather than the whole chain. The dependency's reuse setting is not consulted at that point.
No build-configuration-level setting marks a snapshot dependency as one that must always be rebuilt on every re-run.
Resolution
Per run, in the UI
Re-run the build through the Run custom build dialog and open its Dependencies tab. The tab lists the upstream builds and allows each one to be rebuilt anew instead of reused.
This applies to a single run and has to be repeated on each re-run.
Scripted, through the REST API
Triggering the run through the REST API makes the rebuild part of the request rather than a manual choice. Send a POST to /app/rest/buildQueue with the required BuildTriggeringOptions inside the Build entity.
Rebuild every dependency in the chain:
<build>
<triggeringOptions rebuildAllDependencies="true"/>
<buildType id="buildConfID"/>
</build>
The same request in JSON:
{
"buildType": { "id": "buildConfID" },
"triggeringOptions": { "rebuildAllDependencies": true }
}
Setting rebuildAllDependencies to true prevents the build from reusing any of its snapshot dependency builds and re-runs all dependency configurations.
Rebuild only specific dependencies:
<build>
<triggeringOptions rebuildAllDependencies="false" rebuildFailedOrIncompleteDependencies="false">
<rebuildDependencies>
<buildType id="dependencyBuildConfID"/>
</rebuildDependencies>
</triggeringOptions>
<buildType id="buildConfID"/>
</build>
rebuildDependencies holds the list of snapshot dependencies that should be rebuilt, and is honored only when both rebuildAllDependencies and rebuildFailedOrIncompleteDependencies are false.
Other triggering options
| Field | Effect |
|---|---|
cleanSources |
The agent clears its build checkout directory and pulls all sources anew |
cleanSourcesInAllDependencies |
Applies the cleanSources behavior to all snapshot dependency builds |
rebuildFailedOrIncompleteDependencies |
Re-runs all failed, failed to start, and canceled snapshot dependency builds |
queueAtTop |
Places the build at the top spot of the build queue |
The Kotlin DSL property reuseBuilds = ReuseBuilds.NO on a snapshot dependency is the DSL form of Do not run new build if there is a suitable one. It carries the same limitation: it governs normal triggering, not re-runs.
Comments
0 comments
Please sign in to leave a comment.