Skip to content

Instantly share code, notes, and snippets.

View x-cray's full-sized avatar

Denys Parchenko x-cray

View GitHub Profile
@x-cray
x-cray / high-priority-warnings.groovy
Created April 11, 2012 12:23
Display high-priority warnings from the Jenkins Warnings Plugin on the build summary page
if (manager.build.result == hudson.model.Result.FAILURE) {
warningsResultActions = manager.build.actions.findAll { it.class.simpleName == "WarningsResultAction" }
if (warningsResultActions.size() > 0) {
summary = null
warningsResultActions.each {
newWarnings = it.result.newWarnings
if (newWarnings.size() > 0) {
@x-cray
x-cray / sonar-report.groovy
Last active July 3, 2019 09:23
Jenkins email-ext plugin groovy template. Generates daily Sonar violations report grouped by culprits.
<!DOCTYPE html>
<head>
<title>Sonar violations report</title>
<style type="text/css">
body
{
margin: 0px;
padding: 15px;
}
@x-cray
x-cray / build-report.groovy
Created May 29, 2012 13:17
Jenkins email-ext plugin groovy template. Generates build report. Based on http://techkriti.wordpress.com/2008/08/30/using-groovy-with-hudson-to-send-rich-text-email/
<!DOCTYPE html>
<head>
<title>Build report</title>
<style type="text/css">
body
{
margin: 0px;
padding: 15px;
}
@x-cray
x-cray / entrypoint.sh
Created November 23, 2015 12:36
Docker entrypoint script for adding host address to /etc/hosts
#!/bin/sh
set -e
DOCKERHOST=$(ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print $2 }')
echo "$DOCKERHOST dockerhost" >> /etc/hosts
exec "$@"
@x-cray
x-cray / reload-haproxy.sh
Last active December 2, 2015 15:13
Gracefully reloads HAProxy configuration on Linux
#!/bin/bash
iptables -I INPUT -p tcp --dport 80 --syn -j DROP
sleep 0.2
systemctl reload haproxy
iptables -D INPUT -p tcp --dport 80 --syn -j DROP
@x-cray
x-cray / service.json
Last active December 22, 2015 14:07
Sample Marathon app payload
{
"id": "/app/production/test-server",
"labels": {
"version": "master-ef5a154e25b268c611006d08a78a3ec0a451e7ed-56",
"environment": "production"
},
"env": {
"SERVICE_TAGS": "production,internal-listen-http-3000",
"SERVICE_NAME": "test-server"
},
@x-cray
x-cray / gen-service-defs.sh
Last active December 9, 2015 09:59
Generates versioned Marathon app definition JSON files
#!/bin/bash
set -e
VERSION="$CI_BRANCH-$CI_COMMIT-$CI_BUILD_NUMBER"
declare -A TARGETS=(
[test-server]="."
)
# Set version in service.json
@x-cray
x-cray / service.json
Last active December 22, 2015 14:02
Marathon app payload template
{
"id": "/app/$environment/test-server",
"labels": {
"version": "$tag",
"environment": "$environment"
},
"env": {
"SERVICE_TAGS": "$environment,internal-listen-http-3000",
"SERVICE_NAME": "test-server"
},
@x-cray
x-cray / .drone.yml
Created December 9, 2015 11:09
Drone build configuration
build:
image: registry.local/buildimage-nodejs:latest
commands:
- tools/gen-service-defs.sh
publish:
docker:
image: plugins/drone-docker
repo: registry.local/test-server
tag:
@x-cray
x-cray / Dockerfile
Created December 15, 2015 16:12
Sample base Docker image for Node.js
FROM node:4
RUN apt-get update && apt-get install -y jq && \
rm -rf /var/lib/apt/lists/*
ADD service-wrapper.sh /usr/bin/
ADD entrypoint.sh /usr/bin/