feat(skipPlugins): add option to skip install of plugins

This commit is contained in:
Tobia De Koninck 2024-09-27 16:49:33 +02:00
parent 7cdffbe716
commit fbaffc4e83
4 changed files with 21 additions and 0 deletions

View File

@ -376,6 +376,12 @@ type JenkinsMaster struct {
// +optional
LatestPlugins *bool `json:"latestPlugins,omitempty"`
// Allow to skip installation of both BasePlugins and Plugins.
// Requires using a custom image which includes the BasePlugins.
// Defaults to false.
// +optional
SkipPlugins *bool `json:"skipPlugins,omitempty"`
// DisableCSRFProtection allows you to toggle CSRF Protection on Jenkins
DisableCSRFProtection bool `json:"disableCSRFProtection"`

View File

@ -147,6 +147,9 @@ spec:
description: Master represents Jenkins master pod properties and Jenkins
plugins. Every single change here requires a pod restart.
properties:
skipPlugins:
description: Allow to skip installation of both BasePlugins and Plugins. Requires using a custom image which includes the BasePlugins. Defaults to false.
type: boolean
annotations:
additionalProperties:
type: string

View File

@ -13,6 +13,9 @@ import (
)
func (r *JenkinsBaseConfigurationReconciler) verifyPlugins(jenkinsClient jenkinsclient.Jenkins) (bool, error) {
if r.Configuration.Jenkins.Spec.Master.SkipPlugins != nil && *r.Configuration.Jenkins.Spec.Master.SkipPlugins {
return true, nil
}
allPluginsInJenkins, err := jenkinsClient.GetPlugins(fetchAllPlugins)
if err != nil {
return false, stackerr.WithStack(err)

View File

@ -36,6 +36,7 @@ mkdir -p {{ .JenkinsHomePath }}/scripts
cp {{ .JenkinsScriptsVolumePath }}/*.sh {{ .JenkinsHomePath }}/scripts
chmod +x {{ .JenkinsHomePath }}/scripts/*.sh
{{if not .SkipPlugins }}
{{- $jenkinsHomePath := .JenkinsHomePath }}
{{- $installPluginsCommand := .InstallPluginsCommand }}
@ -58,6 +59,7 @@ EOF
{{ $installPluginsCommand }} --verbose --latest {{ .LatestPlugins }} -f {{ .JenkinsHomePath }}/user-plugins.txt
echo "Installing plugins required by user - end"
{{end}}
`))
func buildConfigMapTypeMeta() metav1.TypeMeta {
@ -73,6 +75,11 @@ func buildInitBashScript(jenkins *v1alpha2.Jenkins) (*string, error) {
latestP = new(bool)
*latestP = true
}
skipPlugins := jenkins.Spec.Master.SkipPlugins
if skipPlugins == nil {
skipPlugins = new(bool)
*skipPlugins = false
}
data := struct {
JenkinsHomePath string
InitConfigurationPath string
@ -81,6 +88,7 @@ func buildInitBashScript(jenkins *v1alpha2.Jenkins) (*string, error) {
BasePlugins []v1alpha2.Plugin
UserPlugins []v1alpha2.Plugin
LatestPlugins bool
SkipPlugins bool
}{
JenkinsHomePath: getJenkinsHomePath(jenkins),
InitConfigurationPath: jenkinsInitConfigurationVolumePath,
@ -89,6 +97,7 @@ func buildInitBashScript(jenkins *v1alpha2.Jenkins) (*string, error) {
InstallPluginsCommand: installPluginsCommand,
JenkinsScriptsVolumePath: JenkinsScriptsVolumePath,
LatestPlugins: *latestP,
SkipPlugins: *skipPlugins,
}
output, err := render.Render(initBashTemplate, data)