[JIRA] (JENKINS-62152) Job changes via script lost after jenkins restart

6 views
Skip to first unread message

nahuel.cassinari@jamf.com (JIRA)

unread,
May 4, 2020, 6:16:03 AM5/4/20
to jenkinsc...@googlegroups.com
Nahuel Cassinari created an issue
 
Jenkins / Bug JENKINS-62152
Job changes via script lost after jenkins restart
Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 2020-05-04 10:15
Priority: Blocker Blocker
Reporter: Nahuel Cassinari

Hello,

We are trying to change git credentials in more than 200 jobs and so we are using a groovy script to do a bulk change:

import com.cloudbees.hudson.plugins.folder.Folder
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
import com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSourcedef pipelines = Hudson.instance.getAllItems(WorkflowMultiBranchProject)def pipelinesUsingCredentials = pipelines.findAll { p -> 
  p.getSCMSources().findAll { 
    it.class == BitbucketSCMSource && it.credentialsId == 'Credential1' 
  } 
}println "pipelines: ${pipelines.size()}"
println "pipelines using svnbuild.core: ${pipelinesUsingCredentials.size()}"pipelinesUsingCredentials.each { println "${it.name.padRight(30)} -- $it.fullName " }def updatePipeline(p) {  
  def sources = p.getSCMSources().findAll { it.class == BitbucketSCMSource && it.credentialsId == 'Credential1' }
  sources.each { source ->
    println "  updating source: ${source.repository}"
    println "  existing credential id: ${source.credentialsId}"
    it.credentialsId = 'Credential2'
    println "  new credential id: ${source.credentialsId}"
  }
}pipelinesUsingCredentials.each { updatePipeline(it) }

The scripts is working ok but we noticed that every time we restart jenkins the value changed back to the old credentials. I checked and seems that the problem is because is not writing the changes in the config.xml of each job. Is this a normal behavior?

 

Thanks!

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

dbeck@cloudbees.com (JIRA)

unread,
May 4, 2020, 10:47:04 AM5/4/20
to jenkinsc...@googlegroups.com
Daniel Beck closed an issue as Not A Defect
 

This is an issue tracker, not a support site. Please ask for help in chat or on the users mailing list.

Change By: Daniel Beck
Status: Open Closed
Resolution: Not A Defect

nahuel.cassinari@jamf.com (JIRA)

unread,
May 4, 2020, 11:32:04 AM5/4/20
to jenkinsc...@googlegroups.com
Nahuel Cassinari commented on Bug JENKINS-62152
 
Re: Job changes via script lost after jenkins restart

Daniel Beck

So that means that this is a normal behavior, not a bug, right?

Reply all
Reply to author
Forward
0 new messages