Skip to content

Commit

Permalink
Merge pull request #356 from jkhelil/issue_351
Browse files Browse the repository at this point in the history
Reconcile yaml user configuration before groovy one
  • Loading branch information
tomaszsek authored Apr 30, 2020
2 parents c82b6a1 + ad6f994 commit 7445915
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/controller/jenkins/configuration/user/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,26 @@ func (r *ReconcileUserConfiguration) ensureSeedJobs() (reconcile.Result, error)
}

func (r *ReconcileUserConfiguration) ensureUserConfiguration(jenkinsClient jenkinsclient.Jenkins) (reconcile.Result, error) {
groovyClient := groovy.New(jenkinsClient, r.Client, r.logger, r.Configuration.Jenkins, "user-groovy", r.Configuration.Jenkins.Spec.GroovyScripts.Customization)

requeue, err := groovyClient.WaitForSecretSynchronization(resources.GroovyScriptsSecretVolumePath)
configurationAsCodeClient := casc.New(jenkinsClient, r.Client, r.logger, r.Configuration.Jenkins)
requeue, err := configurationAsCodeClient.Ensure(r.Configuration.Jenkins)
if err != nil {
return reconcile.Result{}, err
}
if requeue {
return reconcile.Result{Requeue: true}, nil
}
requeue, err = groovyClient.Ensure(func(name string) bool {
return strings.HasSuffix(name, ".groovy")
}, groovy.AddSecretsLoaderToGroovyScript(resources.GroovyScriptsSecretVolumePath))

groovyClient := groovy.New(jenkinsClient, r.Client, r.logger, r.Configuration.Jenkins, "user-groovy", r.Configuration.Jenkins.Spec.GroovyScripts.Customization)
requeue, err = groovyClient.WaitForSecretSynchronization(resources.GroovyScriptsSecretVolumePath)
if err != nil {
return reconcile.Result{}, err
}
if requeue {
return reconcile.Result{Requeue: true}, nil
}

configurationAsCodeClient := casc.New(jenkinsClient, r.Client, r.logger, r.Configuration.Jenkins)
requeue, err = configurationAsCodeClient.Ensure(r.Configuration.Jenkins)
requeue, err = groovyClient.Ensure(func(name string) bool {
return strings.HasSuffix(name, ".groovy")
}, groovy.AddSecretsLoaderToGroovyScript(resources.GroovyScriptsSecretVolumePath))
if err != nil {
return reconcile.Result{}, err
}
Expand Down

0 comments on commit 7445915

Please sign in to comment.