Skip to content

Commit

Permalink
Proper fix for #797
Browse files Browse the repository at this point in the history
  • Loading branch information
brokenpip3 committed Mar 18, 2023
1 parent 2678282 commit b862de9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha2/jenkins_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ type JenkinsMaster struct {
// +optional
Plugins []Plugin `json:"plugins,omitempty"`

// Allow to override jenkins-plugin-cli default behavior
// while donwloading the plugin and dependencies
// see: https://github.com/jenkinsci/plugin-installation-manager-tool#cli-options
LatestPlugins bool `json:"latestPlugins"`

// DisableCSRFProtection allows you to toggle CSRF Protection on Jenkins
DisableCSRFProtection bool `json:"disableCSRFProtection"`

Expand Down
9 changes: 7 additions & 2 deletions chart/jenkins-operator/crds/jenkins-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ spec:
- resources
type: object
type: array
latestPlugins:
description: 'Allow to override jenkins-plugin-cli default behavior
while donwloading the plugin and dependencies, see:
https://github.com/jenkinsci/plugin-installation-manager-tool#cli-options'
type: boolean
disableCSRFProtection:
description: DisableCSRFProtection allows you to toggle CSRF Protection
on Jenkins
Expand Down Expand Up @@ -3119,8 +3124,8 @@ spec:
type: object
type: array
seedJobAgentImage:
type: string
description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.'
type: string
description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.'
seedJobs:
description: 'SeedJobs defines list of Jenkins Seed Job configurations
More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines'
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/jenkins.io_jenkins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,11 @@ spec:
- resources
type: object
type: array
latestPlugins:
description: 'Allow to override jenkins-plugin-cli default behavior
while donwloading the plugin and dependencies, see:
https://github.com/jenkinsci/plugin-installation-manager-tool#cli-options'
type: boolean
disableCSRFProtection:
description: DisableCSRFProtection allows you to toggle CSRF Protection
on Jenkins
Expand Down Expand Up @@ -3120,7 +3125,7 @@ spec:
type: array
seedJobAgentImage:
type: string
description: SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.
description: 'SeedJobAgentImage defines the image that will be used by the seed job agent. If not defined jenkins/inbound-agent:4.10-3 will be used.'
seedJobs:
description: 'SeedJobs defines list of Jenkins Seed Job configurations
More info: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration#configure-seed-jobs-and-pipelines'
Expand Down
4 changes: 2 additions & 2 deletions pkg/configuration/base/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func (r *JenkinsBaseConfigurationReconciler) verifyPlugins(jenkinsClient jenkins
continue
}
if found, ok := isPluginVersionCompatible(allPluginsInJenkins, plugin); !ok {
r.logger.V(log.VWarn).Info(fmt.Sprintf("Incompatible plugin '%s' version, actual '%+v'", plugin, found.Version))
status = false
r.logger.V(log.VWarn).Info(fmt.Sprintf("The plugin you specified as code is incompatible with this jenkins version: plugin '%s' version, actual '%+v'", plugin, found.Version))

}
}
}
Expand Down
14 changes: 12 additions & 2 deletions pkg/configuration/base/resources/scripts_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cat > {{ .JenkinsHomePath }}/base-plugins.txt << EOF
{{ end }}
EOF
{{ $installPluginsCommand }} --verbose --latest=false -f {{ .JenkinsHomePath }}/base-plugins.txt
{{ $installPluginsCommand }} --verbose --latest {{ .LatestPlugins }} -f {{ .JenkinsHomePath }}/base-plugins.txt
echo "Installing plugins required by Operator - end"
echo "Installing plugins required by user - begin"
Expand All @@ -56,7 +56,7 @@ cat > {{ .JenkinsHomePath }}/user-plugins.txt << EOF
{{ end }}
EOF
{{ $installPluginsCommand }} --verbose --latest=false -f {{ .JenkinsHomePath }}/user-plugins.txt
{{ $installPluginsCommand }} --verbose --latest {{ .LatestPlugins }} -f {{ .JenkinsHomePath }}/user-plugins.txt
echo "Installing plugins required by user - end"
`))

Expand All @@ -68,20 +68,30 @@ func buildConfigMapTypeMeta() metav1.TypeMeta {
}

func buildInitBashScript(jenkins *v1alpha2.Jenkins) (*string, error) {

defaultlatestPlugin := true

latestP := jenkins.Spec.Master.LatestPlugins
if !latestP {
latestP = defaultlatestPlugin
}

data := struct {
JenkinsHomePath string
InitConfigurationPath string
InstallPluginsCommand string
JenkinsScriptsVolumePath string
BasePlugins []v1alpha2.Plugin
UserPlugins []v1alpha2.Plugin
LatestPlugins bool
}{
JenkinsHomePath: getJenkinsHomePath(jenkins),
InitConfigurationPath: jenkinsInitConfigurationVolumePath,
BasePlugins: jenkins.Spec.Master.BasePlugins,
UserPlugins: jenkins.Spec.Master.Plugins,
InstallPluginsCommand: installPluginsCommand,
JenkinsScriptsVolumePath: JenkinsScriptsVolumePath,
LatestPlugins: latestP,
}

output, err := render.Render(initBashTemplate, data)
Expand Down

0 comments on commit b862de9

Please sign in to comment.