Last active
July 9, 2025 12:53
-
-
Save Java4all/7c82c302b063f538031d736a86e43991 to your computer and use it in GitHub Desktop.
Jenkins CB plugin managment over casc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CloudBees CI (the enterprise version of Jenkins) uses Configuration as Code (CasC) bundles to manage plugins in a scalable, automated, and version-controlled way. Here's a detailed breakdown of how plugin management works within CasC bundles: | |
A. What Is a CasC Bundle? | |
A CasC bundle is a structured collection of YAML files that define the configuration of a CloudBees CI instance — including plugins, security, jobs, RBAC, and more. These bundles can be stored in Git and applied automatically to controllers via the CloudBees Operations Center. | |
B. Plugin Management via CasC | |
1. plugins.yaml File | |
This file lists all plugins that should be installed on a controller. It supports both CAP (CloudBees Assurance Program) plugins and custom plugins. | |
Example: | |
plugins: | |
- id: "git" | |
- id: "workflow-aggregator" | |
- id: "cloudbees-casc-client" | |
Each plugin is identified by its short ID. | |
Versions are managed automatically via CAP unless overridden. | |
2. plugin-catalog.yaml (Optional) | |
Used to define custom plugin catalogs, including plugins not in CAP or plugins with specific versions. | |
Example: | |
type: "plugin-catalog" | |
version: "1" | |
name: "custom-catalog" | |
configurations: | |
- includePlugins: | |
my-custom-plugin: | |
url: "https://example.com/plugins/my-custom-plugin.hpi" | |
This allows you to: | |
- Include plugins from external URLs | |
- Override CAP restrictions | |
- Define plugin metadata | |
C. How CloudBees Applies Plugins from CasC | |
Bundle is created or exported from a running instance or manually authored. | |
plugins.yaml and plugin-catalog.yaml are placed inside the bundle folder. | |
The bundle is uploaded to the Operations Center or retrieved from Git. | |
CloudBees CI applies the bundle to the controller: | |
- Installs listed plugins | |
- Validates compatibility | |
- Honors CAP rules unless overridden | |
Plugin updates can be triggered via CLI or UI. | |
Challenges in Plugin Installation During Migration | |
1. No Declarative Plugin Install via CasC | |
In CloudBees, plugins are declared in plugins.yaml and installed automatically. | |
Jenkins OSS doesn’t support plugin installation as part of CasC — you'll need to: | |
Install plugins manually via web UI | |
Or script installs using CLI or tools like Plugin Installation Manager | |
2. Version Management is Manual | |
CloudBees locks plugin versions using CAP for stability. | |
Jenkins OSS relies on latest versions from the update center, which may break dependencies or cause regressions. | |
You’ll need to pin versions manually if stability is critical. | |
3. Installing Proprietary or CloudBees-Only Plugins | |
Plugins like cloudbees-folder, rbac, and quiet-start won’t be available in Jenkins OSS. | |
If your CasC bundle references them, you’ll need to: | |
Remove them | |
Or replace with open-source alternatives (if available) | |
4. Update Center Restrictions | |
Jenkins OSS uses the public update center (updates.jenkins.io) — plugin availability may differ from CloudBees’ curated catalog. | |
Plugins may require newer core versions, forcing Jenkins upgrades you weren’t planning. | |
Jenkins OSS supports deploying plugins using Groovy scripts placed in its startup init directory, typically under: | |
$JENKINS_HOME/init.groovy.d/ | |
This mechanism is part of Jenkins' startup lifecycle: any Groovy script placed in this folder will be executed automatically when Jenkins starts. | |
How Plugin Installation via Groovy Works | |
Automatically install plugins | |
Configure plugin settings | |
Seed jobs or system config | |
Useful for Docker images, provisioning, and reproducible builds | |
Folder Setup | |
Place your script in: | |
/var/lib/jenkins/init.groovy.d/00-install-plugins.groovy | |
The prefix (00-, 01-) can help with ordering if multiple scripts exist. | |
Example: Install Plugins from List | |
import jenkins.model.* | |
import hudson.PluginManager | |
import hudson.PluginWrapper | |
def pluginList = [ | |
'git', | |
'workflow-aggregator', | |
'credentials' | |
] | |
def instance = Jenkins.getInstance() | |
def pm = instance.getPluginManager() | |
def uc = instance.getUpdateCenter() | |
pluginList.each { pluginId -> | |
if (!pm.getPlugin(pluginId)) { | |
def plugin = uc.getPlugin(pluginId) | |
if (plugin) { | |
println "Installing plugin: $pluginId" | |
plugin.deploy() | |
} else { | |
println "Plugin not found in update center: $pluginId" | |
} | |
} else { | |
println "Plugin already installed: $pluginId" | |
} | |
} | |
🧼 Best Practices | |
Ensure internet access if using update center downloads | |
Use deterministic plugin version management if reproducibility matters | |
For offline installs, drop .hpi files in $JENKINS_HOME/plugins/ and script plugin enabling |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment