Skip to content

Instantly share code, notes, and snippets.

View legege's full-sized avatar

Georges-Etienne Legendre legege

View GitHub Profile
@legege
legege / cleanup.groovy
Created March 23, 2018 16:41
Intelligently clean a Sonatype Nexus3 repository... keep the last X released versions of each "major.minor" artifact
import org.sonatype.nexus.repository.storage.Component
import org.sonatype.nexus.repository.storage.StorageFacet;
def retentionCount = 15
def repositoryName = 'releases'
def dryRun = true
log.info("Cleanup script started! Dry Run Mode: $dryRun");
def repo = repository.repositoryManager.get(repositoryName);
def tx = repo.facet(StorageFacet.class).txSupplier().get();
@legege
legege / scan-assets.groovy
Created March 22, 2018 19:06
Nexus 3 assets scan
import org.apache.commons.io.FileUtils
import org.sonatype.nexus.repository.storage.Asset
import org.sonatype.nexus.repository.storage.Component;
import org.sonatype.nexus.repository.storage.Query
import org.sonatype.nexus.repository.storage.Query.Builder;
import org.sonatype.nexus.repository.storage.StorageFacet
def repo = repository.repositoryManager.get('releases')
StorageFacet storageFacet = repo.facet(StorageFacet)
@legege
legege / gist:71055dd04b0c89f51d8f
Created December 1, 2015 18:40
Generate chcp.json and chcp.manifest with Gulp
// generate chcp.manifest
gulp.task('chcp-manifest', ['index'], function() {
return gulp.src(['**/*', '!chcp.*'], { cwd: path.join(targetDir, '') })
.pipe(plugins.buster({ fileName: 'chcp.manifest', algo: 'md5', transform: function(hashes) {
var transformed = [];
for (var file in hashes) {
transformed.push({ file: file, hash: hashes[file] });
}
return transformed;
}}))
@legege
legege / jenkins-job-dsl.groovy
Last active September 25, 2018 16:53 — forked from stuartstevenson/jenkins-job-dsl.groovy
Jenkins Job DSL with distributed job config files on GitLab. The seed.groovy file scans GitLab for all your projects for .jenkins-ci.groovy files and runs them centrally.
mavenJob("${name}") {
goals('clean install findbugs:findbugs pmd:pmd cobertura:cobertura')
logRotator {
numToKeep(5)
artifactNumToKeep(1)
}
scm {
git {
@legege
legege / cleanrepo.sh
Last active May 6, 2024 20:56
Intelligently clean a Sonatype Nexus repository... keep the last 2 released versions of each "major.minor" artifact
#!/bin/bash
DRY_RUN=1
if [ "$1" != "" ]; then
DRY_RUN="$1"
fi
MAX_VERSION=2
if [ "$2" != "" ]; then
MAX_VERSION="$2"
fi
@legege
legege / client.js
Last active March 3, 2018 18:19
Primus.io: How to do two-way SSL
var fs = require('fs');
var Primus = require('primus');
var Socket = Primus.createSocket({ transformer: 'websockets' });
var socket = new Socket('https://localhost:8443', { transport: {
key: fs.readFileSync('client.key'),
cert: fs.readFileSync('client.crt'),
rejectUnauthorized: false
} });
@legege
legege / mjpeg-directives.html
Created April 3, 2013 14:02
This is an AngularJS directive for MJPEG streams. This directive uses an iframe to stop the browser from loading the MJPEG stream. This is useful for Chrome: https://code.google.com/p/chromium/issues/detail?id=73395
<mjpeg url="videoUrl"></mjpeg>