It looks like the job-dsl plugin doesn't always update the script approval when the job already exists. This is causing us deployment issues and I'm willing to try help/fix if I can.
What I did so far to reproduce this:
1) Make snapshot of Jenkins
2) Create a dsl job called "job-dsl-testing" that will create a dummy "helloworld" pipeline
3) Run job-dsl-testing and then the helloworld pipeline => runs as expected. Pipeline is created and runs fine.
4) Copy these two jobs to another machine (scp)
5) Restore the snapshot of Jenkins and copy back the jobs (scp)
6) Run the helloworld => failure, "UnapprovedUsageException"
7) Run job-dsl-testing and then the helloworld pipeline => Still fails with "UnapprovedUsageException". I would have expected this to work.
8) Delete config.xml of the helloworld pipile, job-dsl-testing and then the helloworld pipeline => Works.
Also, checking the ScriptApproval.xml shows an entry was added after step 8.
1) Edit the job-dsl-testing, so the pipeline script of the helloworld pipeline would be slightly different
2) Run job-dsl-testing and then the helloworld pipeline => works as expected. Pipeline is updated and runs fine.
So my conclusion is that in some corner cases, the script approval doesn't get updated the a job dsl is processed.
For us, this is a problem as we rely heavily on job seeding. Having these UnapprovedUsageException is making our deployment much more difficult.