Skip to content

Instantly share code, notes, and snippets.

@jbravo
jbravo / pipeline.groovy
Created May 19, 2024 16:03 — forked from lvthillo/pipeline.groovy
Scripted Jenkins pipeline which uses Kubernetes plugin
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'git', image: 'alpine/git', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]
) {
node('mypod') {
@jbravo
jbravo / delete-from-v2-docker-registry.md
Created July 17, 2020 12:23 — forked from jaytaylor/delete-from-v2-docker-registry.md
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@jbravo
jbravo / README.md
Created October 1, 2019 22:33 — forked from beercanx/README.md
Retry, Continue or Abort (Jenkins Pipeline) with Colour Support

Create test Jenkins

docker run -it --rm --name jenkins -p '8080:8080' jenkins:alpine

Install

  • Login as Admin
  • Accept the standard plugins
  • Continue as Admin
  • Install AnsiColor plugin
@jbravo
jbravo / nexus-repo-manager-privilege-example.groovy
Created January 26, 2019 17:56 — forked from nblair/nexus-repo-manager-privilege-example.groovy
A groovy script to create Content Selectors, privileges, and roles programmatically via the Nexus Repository Manager 3 Scripting API.
import org.sonatype.nexus.common.entity.*
import org.sonatype.nexus.security.*
import org.sonatype.nexus.security.authz.*
import org.sonatype.nexus.selector.*
import com.google.common.collect.ImmutableMap
// use container.lookup to fetch internal APIs we need to use
def selectorManager = container.lookup(SelectorManager.class.name)
def securitySystem = container.lookup(SecuritySystem.class.name)
@jbravo
jbravo / bash-colors.md
Created November 16, 2018 21:15 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes.

Regular Colors

Value Color
\e[0;30m Black
\e[0;31m Red
\e[0;32m Green
\e[0;33m Yellow
\e[0;34m Blue
\e[0;35m Purple
@jbravo
jbravo / pipelineChooseDockerTags.groovy
Created May 24, 2018 20:57 — forked from m-x-k/pipelineChooseDockerTags.groovy
Jenkins pipeline - choose docker tags
/*
* Displays input dropdown select containing docker image tags
* Manage Jenkins->Script Approval (required)
*/
node {
stage('chooseDockerTags') {
def image = "IMAGE"
def url = "https://LOCAL-DOCKER-REG:5000/v2/${image}/tags/list"
def list = getDockerImageTags(url)
#!/bin/sh
#
# This script adds 2 spring repositories to Nexus using curl
#
NEXUS_URL="http://${EVENTDRIVENMICROSERVICESPLATFORM_NEXUS_1_PORT_8081_TCP_ADDR}:${EVENTDRIVENMICROSERVICESPLATFORM_NEXUS_1_PORT_8081_TCP_PORT}/nexus"
POST_REPO_SERVICE="/service/local/repositories"
GET_REPO_SERVICE="/service/local/repositories"
PUT_PUBLIC_REPO_SERVICE="/service/local/repo_groups/public"
@jbravo
jbravo / gitcheats.txt
Created April 6, 2017 18:26 — forked from amaksoft/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# get most modified files and counts
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | sort -g
# Locally checkout all remote branches of a repository
git branch -r | cut -d '/' -f2 | grep -Ev '( |master)' | xargs -Ibranch git checkout -b branch origin/branch
# Open current Git repository URL
@jbravo
jbravo / Jenkinsfile
Created April 6, 2017 18:17 — forked from amaksoft/Jenkinsfile
My example Jenkins Pipeline setup for Android app project
#!/usr/bin/groovy
/*
* Copyright (c) 2016, Andrey Makeev <amaksoft@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
@jbravo
jbravo / example_from_gist.groovy
Created March 30, 2016 22:15 — forked from thomasleveil/example_from_gist.groovy
Jenkins DSL job example
job('Example from gist') {
steps {
shell('''
echo "hello world from gist"
'''.stripIndent())
}
}