-1

I would like to remove the authToken on existing jobs. When we run a provisioner script it created the authToken=secret, now we want to remove it.

This is how it was created:

    configure { project ->
        ( project / 'authToken' ).setValue('secret')
    }                

Removing that code doesn't remove the actual job setting.

ISZ
  • 1,027
  • 2
  • 14
  • 29

2 Answers2

0

I was able to solve by removing the Jobs DSL described in the question, but then also following it up by running a script in the console window in Jenkins UI using the following:

import hudson.security.*

def h = Hudson.getInstance() 

for (item in h.items) {

  if(item instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob) {

    println item.name + ' ' + item.getClass()

    if(item.name == 'test-job-with-token-equals-secret-defined') {
      def pipeline = org.jenkinsci.plugins.workflow.job.WorkflowJob.class 
      def field = pipeline.getDeclaredField("authToken") 
      field.setAccessible(true) 
      field.set(item, null)
    }
  }
}

By running this script, the job confuguration Trigger builds remotely (e.g., from scripts) was unchecked, which is the end state I was looking for, and so now it should stay this way when initializing all jobs using Jobs DSL described above.

ISZ
  • 1,027
  • 2
  • 14
  • 29
0

This is a known problem in Jenkins, see JENKINS-21017. It has been fixed in Jenkins 2.99.

daspilker
  • 8,154
  • 1
  • 35
  • 49