Skip to content

Instantly share code, notes, and snippets.

jenkins_create_token() {
local user=$1 pass=$2 name=$3 jurl=$4
# Get CSRF crumb
local crumb
crumb=$(curl -s -u "$user:$pass" \
"$jurl/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)")
# Create token
curl -s -u "$user:$pass" \
# Instance ID
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
# Region
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document \
| jq -r '.region')
# Fetch the "Name" tag
NAME=$(aws ec2 describe-tags \
--region $REGION \
inal Version — jenkins_audit.py
python
#!/usr/bin/env python3
import argparse
import os
import requests
from packaging.version import Version, InvalidVersion
from tabulate import tabulate
@Java4all
Java4all / gist:0c9206c687633c2030650d5f523eb99b
Last active July 12, 2025 00:45
Plugins dependency check
# cli.py
import argparse
import os
from main import analyze_plugin
def main():
parser = argparse.ArgumentParser(
description="\U0001F9E9 Jenkins Plugin Compatibility Analyzer",
formatter_class=argparse.ArgumentDefaultsHelpFormatter
# Directory where plugin .hpi files will be stored
# File: plugins.yaml
# Define plugins with specific versions
# Example YAML file to track plugin versions
---
plugins:
- name: git
version: 5.1.0
import jenkins.model.*
import hudson.PluginWrapper
import java.nio.file.*
def pluginDir = new File(Jenkins.instance.rootDir, "plugins")
def pluginList = [
[name: "git", version: "5.2.1"],
[name: "workflow-job", version: "2.40"]
]
@Java4all
Java4all / gist:7c82c302b063f538031d736a86e43991
Last active July 9, 2025 12:53
Jenkins CB plugin managment over casc
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.
@Java4all
Java4all / gist:f5032a0aac9c5aff1cea96ad9fa7ddd5
Created July 9, 2025 07:01
What is plugins in Jenkins?
1. What Is a Plugin in Jenkins?
A Jenkins plugin is a self-contained Java archive (.hpi or .jpi file) that extends Jenkins' core functionality. Plugins allow Jenkins to integrate with tools like Git, Docker, Maven, Slack, and even custom steps in your pipeline.
They’re the backbone of Jenkins’ flexibility — you can add build triggers, post-build actions, UI elements, pipeline steps, and more.
2. Where Are Plugins Stored?
Jenkins stores plugins in the following location on the controller (master) node:
$JENKINS_HOME/plugins/
Each plugin is stored as a .jpi or .hpi file.
@Java4all
Java4all / gist:9699bc1f421e4000956f322e3f29124e
Last active July 9, 2025 06:51
Jenkins plugins management options
1. Jenkins Plugin Manager CLI
The Jenkins Plugin Manager CLI (jenkins-plugin-manager) is officially recommended, modern, and robust:
- Better dependency resolution.
- Officially supported by Jenkins.
- YAML-based plugin configuration.
2. Step-by-step Automation Guide:
@Java4all
Java4all / upload-to-azure.sh
Created December 6, 2021 20:39 — forked from rtyler/upload-to-azure.sh
A bash script which supports uploading blobs to Azure Storage: ./upload-to-azure.sh [filename]
#!/usr/bin/env bash
FILENAME=${1}
# expected to be defined in the environment
# - AZURE_STORAGE_ACCOUNT
# - AZURE_CONTAINER_NAME
# - AZURE_ACCESS_KEY
# inspired by