Skip to content

Instantly share code, notes, and snippets.

@mehulmpt
mehulmpt / profiles.json
Last active December 11, 2021 09:58
Sample profiles.json for new Windows Terminal
{
"defaultProfile": "{09dc5eef-6840-4050-ae69-21e55e6a2e62}",
"initialRows": 30,
"initialCols": 120,
"alwaysShowTabs": true,
"showTerminalTitleInTitlebar": true,
"experimental_showTabsInTitlebar": true,
"profiles": [
{
"guid": "{09dc5eef-6840-4050-ae69-21e55e6a2e62}",
@eeichinger
eeichinger / clone-repos-generate.sh
Last active December 27, 2023 10:12
Generate a script to clone all repos within a specific project from bitbucket server and bitbucket cloud
# generate a script ./clone-repos.sh from a list of repos fetched via Bitbucket API
# note: requires 'curl' and 'jq' to be installed
set -e
echo -n '' > clone-repos.sh
chmod +x clone-repos.sh
ONPREM_USER=xxxxx
ONPREM_PASS=......
@antonpiatek
antonpiatek / gist:c74991f7ec54126fc91dd66a290d7520
Last active July 21, 2023 10:56 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
// find old workspace folders on any node (master/slave)
// currently only look for deleted branches of multibranch (pipeline?) jobs, and remove them
// also finds builds older than 90 days. Set flags below to true to actually do deletes
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
@ceilfors
ceilfors / cleanupUnusedWorkspaceInSlaves.groovy
Last active September 14, 2023 20:30
When you delete jobs in Jenkins, the corresponding workspaces in the build slaves won't be deleted automatically. This Jenkins script will go to each slave and check if the jobs are already deleted in Jenkins master and delete the workspace.
import com.cloudbees.hudson.plugins.folder.Folder
import hudson.FilePath
import jenkins.model.Jenkins
def boolean isFolder(String name) {
def item = Jenkins.instance.getItemByFullName(name)
return item instanceof Folder
}
def deleteUnusedWorkspace(FilePath root, String path) {
@mgrebenets
mgrebenets / bitbucket-branches-job-dsl.groovy
Created June 8, 2015 01:02
Jenkins Job DSL Example - Bitbucket Branches
//
// Jenkins Job DSL example to create build projects for Bitbucket branches
//
// Imports
import java.text.DateFormat
import java.text.SimpleDateFormat
import groovy.time.TimeCategory
// URL components
@dnozay
dnozay / _Jenkins+Script+Console.md
Last active June 5, 2024 17:43
jenkins groovy scripts collection.
@dnozay
dnozay / script.groovy
Last active June 27, 2019 17:16
Jenkins - add badge & summary to promoted build
// When using the Promoted Build plugin, you may want to perform some operations
// then you may also want to add badges or a summary to the target build as
// opposed to the promotion build. This script assumes that you have a manual
// promotion process with a parameter called RELEASE_VERSION (hence requiring
// user input); the content that follows would be what you put as a Groovy
// Postbuild action on the promotion process.
import org.jvnet.hudson.plugins.groovypostbuild.*;
def add_release_version(promotion) {
@stuartstevenson
stuartstevenson / jenkins-job-dsl.groovy
Created September 16, 2014 07:50
Jenkins job dsl with distributed job config files. The seed.groovy file scans stash repo branches for jenkins-job-dsl.groovy files and runs them centrally.
Closure job = {
// Job Name
name "${stashProjectKey}-${projectName}-${branchSimpleName}"
// Where should jenkins run the job
label ('master')
// Where should Jenkins get the source code from
scm {
git {
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@larrycai
larrycai / README.markdown
Last active September 16, 2022 03:59
check the plugin usage in jenkins