Skip to content

Instantly share code, notes, and snippets.

View NicolasGeraud's full-sized avatar

Nicolas Géraud NicolasGeraud

View GitHub Profile
@NicolasGeraud
NicolasGeraud / addPostHookInBitbucket.py
Created March 3, 2015 22:24
BITBUCKET - How to add POST hook
import urllib
import urllib2
import base64
import json
username = "mail"
password = "passwd"
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
url = 'https://bitbucket.org/api/2.0/repositories/bekom/'
@NicolasGeraud
NicolasGeraud / removeStringProperty.groovy
Last active August 29, 2015 14:16
JENKINS - remove string property
import hudson.model.*
import hudson.plugins.git.*
changeBranche(Jenkins.instance.items)
def changeBranche(items) {
println items.size
for (item in items) {
if (item =~ "Feature*") {
print(item.name)
@NicolasGeraud
NicolasGeraud / addBranchAndRename.groovy
Created March 4, 2015 14:50
JENKINS - add git branch and rename
import hudson.model.*
import hudson.plugins.git.*
changeBranche(Jenkins.instance.items)
def changeBranche(items) {
println items.size
for (item in items) {
if (item =~ "Feature*") {
print(item.name)
@NicolasGeraud
NicolasGeraud / jenkinsRemoveGitLocalBranch.groovy
Created March 4, 2015 16:51
JENKINS - suppression d'un additionnal behaviour Git
import hudson.model.*
import hudson.plugins.git.*
changeBranche(Jenkins.instance.items)
def changeBranche(items) {
for (item in items) {
if (item =~ "Feature*") {
println(item.name)
for (ext in item.scm.extensions) {
@NicolasGeraud
NicolasGeraud / gitIsolerRepertoire.sh
Created March 5, 2015 13:48
GIT - isoler des répertoires et leur historique
git remote rm origin
# Supprime les tags
for tag in `git tag`; do git tag -d $tag; done
# filtrer les commits n'appartenant qu'au module souhaité
git filter-branch -f --prune-empty --index-filter \
'git rm --cached -r -q -- . ; git reset -q $GIT_COMMIT -- dir1 dir2 dir3' -- --all
@NicolasGeraud
NicolasGeraud / gitDirDevientRoot.sh
Created March 5, 2015 13:50
GIT - faire qu'un repertoire devienne le root
git remote rm origin
# Supprime les tags
for tag in `git tag`; do git tag -d $tag; done
# filtrer les commits n'appartenant qu'au module souhaité
git filter-branch --subdirectory-filter dir1 -- --all
@NicolasGeraud
NicolasGeraud / sync_graviteeio_repo.py
Last active July 16, 2016 10:05
clone or fetch all Gravitee.io repositories.
import subprocess
import requests
import os
import sys
if len(sys.argv) < 2:
print("")
print("Usage: sync_gravitee.py [https | ssh]")
print(" clone mode : https or ssh")
sys.exit(1)
@NicolasGeraud
NicolasGeraud / list_jenkins_cron.groovy
Created March 18, 2016 13:42
lister tous les cron des jobs jenkins
for (item in Jenkins.instance.items) {
if ( ! item.disabled ) {
for( trigger in item.triggers) {
if(trigger.value.spec != "") {
println "${item.name} ${trigger.value.spec}"
}
}
}
}
git filter-branch -f --env-filter '
LANG=en_US.utf8
original_git_date="$GIT_COMMITTER_DATE"
cutDate=$(echo $original_git_date | rev | cut -d" " -f2 |rev)
hour=$(date --date "$cutDate" +%H)
day=$(date --date "$cutDate" +%u)
new_git_date=$(date --date "$cutDate" +"%a %b %d %T %Y")
if [ "$hour" -gt "9" ] && [ "$hour" -lt "19" ] && [ "$day" -lt "6" ]
then
new_git_date=$(date --date "$new_git_date 9 hours" +"%a %b %d %T %Y %z")
@NicolasGeraud
NicolasGeraud / sync.sh
Last active January 7, 2017 09:38
sync graviteeio repositories and update master and run maven
for f in *;do if [[ -d $f ]]; then pushd $f 2>&1 1>/dev/null; echo "\n====== $f" && gfa && gco master && gm; popd 2>&1 1>/dev/null; fi; done;
for f in *;do if [[ -d $f ]]; then pushd $f 2>&1 1>/dev/null; if [[ -e "pom.xml" ]]; then echo "\n====== $f" && mvnci; fi; popd 2>&1 1>/dev/null; fi; done;