On Mon, Dec 3, 2018 at 7:49 AM Tony Noble <
tony....@gmail.com> wrote:
> Would it not make sense to for Jenkins to at least attempt to parse the pipeline script when the job is created / amended? Even if it ignores 'stages' and just looks at 'parameters' and 'triggers', that would at least get round not only this issue but also the need to write pipelines in such a way that they don't cause mayhem when running for the first time with no parameter definitions (or with parameter definitions that are no longer correct).
There is discussion of this general issue in JENKINS-41929. Briefly,
for Declarative Pipelines (but not Scripted), we could in principle
parse the definition as soon as the job is created and set the
`List<JobProperty>` accordingly, including parameter definitions, and
probably also preconfigure SCM polling without relying on
`WorkflowRun.checkouts` from an initial build.
Note that for the special case of parameter definitions, the `params`
global variable is defined so that `defaultValue`s of parameters
defined in the job will be honored for the parameterless initial
build, which is a partial workaround.
As to Domi’s suggestion of having polling (on the “main repo”) be set
up automatically for the case of a job using `CpsScmFlowDefinition`,
yes this could work reliably for any Pipeline syntax I think, since
the SCM information is statically available. Feel free to file an RFE
in `workflow-cps-plugin` for it.
Anyway, the broad issue remains that Jenkins maintains a variety of
pieces of state—distinct from configuration—in `$JENKINS_HOME`, and so
if you blow that away, some functionality will be impaired. For the
particular case of SCM state as described here, you can work around
this by defining non-multibranch projects with a different build
trigger structure using the Job DSL plugin or similar job definition
tools, which amounts to much the same thing as Jenkins-X is doing in
`--prow` mode at least in this respect.