The problem is that some plugin (I assume it's Declarative Pipeline) modifies the configuration during or after a build. Job DSL can't differentiate between user changes and automatic changes, so it's will show the warning. IMHO it's debatable if a plugin should modify the job configuration instead of storing the information in build. There are other plugins that also modify the configuration. And that causes issues for other plugins as well, e.g. for the Job Config History plugin.
Configuration generated by Job DSL:
<?xml version="1.0" encoding="UTF-8"?><flow-definition>
<actions/>
<description/>
<keepDependencies>false</keepDependencies>
<properties/>
<triggers/>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition">
<script>
pipeline {
agent any
stages {
stage('build') {
steps {
echo 'building'
}
}
}
}
</script>
<sandbox>false</sandbox>
</definition>
</flow-definition>
Configuration after first build:
<?xml version='1.0' encoding='UTF-8'?>
<flow-definition plugin="workflow-job@2.21">
<actions>
<org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobAction plugin="pipeline-model-definition@1.3.1"/>
</actions>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.53">
<script>
pipeline {
agent any
stages {
stage('build') {
steps {
echo 'building'
}
}
}
}
</script>
<sandbox>false</sandbox>
</definition>
<triggers/>
<disabled>false</disabled>
</flow-definition>
The problem is that some plugin (I assume it's Declarative Pipeline) modifies the configuration during or after a build. Job DSL can't differentiate between user changes and automatic changes, so it's will show the warning. IMHO it's debatable if a plugin should modify the job configuration instead of storing the information in build. There are other plugins that also modify the configuration. And that causes issues for other plugins as well, e.g. for the Job Config History plugin.
Configuration generated by Job DSL:
Configuration after first build: