Skip to content

Instantly share code, notes, and snippets.

@imranansari
imranansari / jenkins-home-git.sh
Created February 4, 2018 16:54 — forked from cenkalti/jenkins-home-git.sh
Backup Jenkins home periodicallly with git.
#!/bin/bash
# Setup
#
# - Create a new Jenkins Job
# - Mark "None" for Source Control Management
# - Select the "Build Periodically" build trigger
# - configure to run as frequently as you like
# - Add a new "Execute Shell" build step
# - Paste the contents of this file as the command
@imranansari
imranansari / master_Dockerfile
Created February 1, 2018 17:30 — forked from twasink/master_Dockerfile
A docker file for a Jenkins master server
FROM jenkins:2.7.1
MAINTAINER Robert Watkins
USER root
RUN mkdir /var/log/jenkins
RUN mkdir /var/cache/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
RUN chown -R jenkins:jenkins /var/cache/jenkins
USER jenkins
data:
build: jenkins-data
master:
build: jenkins-master
volumes:
- .:/backup
volumes_from:
- data
ports:
#!groovy
node {
// Need to replace the '%2F' used by Jenkins to deal with / in the path (e.g. story/...)
// because tests that do getResource will escape the % again, and the test files can't be found
ws("workspace/${env.JOB_NAME}/${env.BRANCH_NAME}".replace('%2F', '_')) {
// Mark the code checkout 'stage'....
stage 'Checkout'
checkout scm
// Mark the code build 'stage'....
@imranansari
imranansari / data_Dockerfile
Created February 1, 2018 17:19 — forked from twasink/data_Dockerfile
Dockerfile for a Jenkins data volume container
# Needs to match the linux version used in jenkins-master
FROM debian:jessie
MAINTAINER Robert Watkins
# user 1000 must match the user id for the jenkins user in jenkins-master
RUN useradd -d "/var/jenkins_home" -u 1000 -m -s /bin/bash jenkins
RUN mkdir -p /var/log/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
@imranansari
imranansari / install_jenkins_plugin.sh
Created January 26, 2018 23:21 — forked from hoesler/install_jenkins_plugin.sh
Script to install one or more jenkins plugins including dependencies while jenkins is offline
#!/usr/bin/env bash
set -e
set -o pipefail
plugin_repo_url="http://updates.jenkins-ci.org/download/plugins"
plugin_dir="/var/lib/jenkins/plugins"
include_optionals=false
showUsage() {
@imranansari
imranansari / goshell.go
Created January 16, 2018 16:22 — forked from lee8oi/goshell.go
Running system commands interactively in Go using os/exec
package main
import (
"os"
"os/exec"
)
func Command(args ...string) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
for i in 1 2 3; do
docker-machine create -d virtualbox swarm-$i
done
eval $(docker-machine env swarm-1)
docker swarm init --advertise-addr $(docker-machine ip swarm-1)
TOKEN=$(docker swarm join-token -q manager)
cd cloud-provisioning
git pull
scripts/dm-swarm.sh
eval $(docker-machine env swarm-1)
docker node ls
# Setup Cluster
for i in 1 2 3; do
docker-machine create -d virtualbox swarm-$i
done
eval $(docker-machine env swarm-1)
docker swarm init --advertise-addr $(docker-machine ip swarm-1)