Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54510

Job dsl doesn't update script approval when job already exists

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins: v2.138.2
      Job dsl plugin: 1.70

      Hi there!

      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:

      First test
      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.

      Second test
      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.

      Conclusion

      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.

      Cheers,

       

          [JENKINS-54510] Job dsl doesn't update script approval when job already exists

          I think this is not a Job DSL issue. Job DSL does not interfere with script approval when generating pipeline jobs.

          The problem is probably step 6. Running the seed job again (step 7) has no effect since Job DSL will not detect a diff to the existing config and thus will not update the config.

          I also think that the setup is questionable. It should suffice to restore the seed job, then run the seed job to generate any other jobs. In this case the pipeline job would be created from scratch without problems.

          Daniel Spilker added a comment - I think this is not a Job DSL issue. Job DSL does not interfere with script approval when generating pipeline jobs. The problem is probably step 6. Running the seed job again (step 7) has no effect since Job DSL will not detect a diff to the existing config and thus will not update the config. I also think that the setup is questionable. It should suffice to restore the seed job, then run the seed job to generate any other jobs. In this case the pipeline job would be created from scratch without problems.

            Unassigned Unassigned
            bernard87 Bernard Landon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: