Skip to content

Instantly share code, notes, and snippets.

Avatar

jakub-bochenski

View GitHub Profile
View tiny-java-http-healthcheck.bash
#!/bin/bash -xe
cat << "JAVA" > Checker.java && javac Checker.java
import java.net.HttpURLConnection;
import java.net.URL;
public class Checker {
public static void main(String[] args) throws Exception {
HttpURLConnection conn =
(HttpURLConnection) new URL(args[0])
.openConnection();
@jakub-bochenski
jakub-bochenski / diff-to-yaml.sh
Created Jul 6, 2018
Output changed file paths and lines based on git diff
View diff-to-yaml.sh
#!/bin/bash -e
path='^\+\+\+ .\/(.*)'
hunk='^@@ -[0-9]+(,[0-9]+|) \+([0-9]+)(,([0-9]+|)|) @@'
while read -r line
do
if [[ $line =~ $path ]]
then
echo "${BASH_REMATCH[1]}:"
fi
@jakub-bochenski
jakub-bochenski / projects-by-scm.groovy
Created Apr 10, 2018
Find all projects building a SCM repository
View projects-by-scm.groovy
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
import org.jenkinsci.plugins.workflow.job.WorkflowJob
import hudson.model.AbstractProject
import jenkins.*;
import jenkins.model.*;
import hudson.*;
import hudson.model.*;
String query = build.envVars['QUERY']
@jakub-bochenski
jakub-bochenski / artifactSummary.groovy
Created Dec 18, 2017
Add summary with build artifacts matching a pattern
View artifactSummary.groovy
def filter = /.log$/
def icon = 'attribute.png'
def header = "<h2>Artifacts matching ${filter}</h2>"
def body = manager.build.artifacts
.findAll { it.relativePath =~ filter }
.collect { "<a href='artifact/${it.href}'>${it.name}</a>" }
.collect { "<li>${it}</li>" }
.join('\\n')
@jakub-bochenski
jakub-bochenski / printJobsDiff.groovy
Last active Nov 23, 2017
Groovy Postbuild script to print a diff of all affected job configurations
View printJobsDiff.groovy
def build = manager.build
def println = { manager.listener.logger.println(it) }
def since = build.startTimeInMillis
println 'Since : '+new Date(since)
def jobs = build
.getActions(javaposse.jobdsl.plugin.actions.GeneratedJobsBuildAction)
@jakub-bochenski
jakub-bochenski / maven-deployer.groovy
Last active Apr 25, 2019 — forked from aleung/pom.xml
A pom.xml to batch deploy artifacts which are put under local repository folder structure to a repository. Modify the setting in <deploy.basefolder> and <distributionManagement> before use. Run `mvn install` to deploy.This file is created base on StackOverflow answer: http://stackoverflow.com/a/3304212/94148 Referenced by http://aleung.github.co…
View maven-deployer.groovy
def layout = session.lookup('org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout');
def repoFactory = session.lookup('org.apache.maven.artifact.repository.ArtifactRepositoryFactory');
def repository = repoFactory.createDeploymentArtifactRepository(
project.distributionManagement.repository.id,
project.distributionManagement.repository.url,
layout, true );
def snapshotRepository = repoFactory.createDeploymentArtifactRepository(
project.distributionManagement.snapshotRepository.id,
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>google-checkstyle-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
View gist:9971998
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.util.Date;
import java.util.Scanner;
public class Container {
You can’t perform that action at this time.