Skip to content

Instantly share code, notes, and snippets.

@prikkeldraad
prikkeldraad / README.md
Created September 25, 2018 11:55
Manual migration svn to git

Preface

When tools like svn2git are not available you need to migratie a svn repository by hand to git. Git has the "git svn" option to make this work albeit not 100%. There are some manual steps needed to migratie trunk, branches and tags. It's even possible to add branches or tags later when a trunk is already migrated to Git. Here's how. Note: In the code examples is used to indicate a field that needs to be filled with one's specific set of data.

Preconditions

@prikkeldraad
prikkeldraad / VersionParser.groovy
Created August 23, 2018 11:24
Groovy class for Jenkins Shared Library to parse version number based on pom.xml and working branch to set version of artifact according to git workflow
#!/usr/bin/env groovy
package com.github.prikkeldraad.git
class VersionParser implements Serializable {
public String number
public String branch
private String _branch
private String _version
private String _build
@prikkeldraad
prikkeldraad / Jenkinsfile_stage_qualitygate.groovy
Created May 8, 2018 06:54
Jenkinsfile stage for SonarQube Quality Gate check
// replace <name> with your values
stage("Quality Gate"){
// get analysisId with the correct name of the build, this can take a while
timeout(time: 3, unit: 'MINUTES') {
waitUntil {
try {
result = httpRequest "http://<sonarqube-instance>/api/project_analyses/search?project=<project-name>:${env.BRANCH_NAME}"
def analyses = readJSON text: result.content
analysisId = analyses.analyses[0].key
@prikkeldraad
prikkeldraad / Jenkinsfile_stage_analysis.groovy
Last active August 13, 2018 07:37
Jenkinsfile with SonarQube analysis stage
stage('Analysis') {
printf("Branch name: %s", "${env.BRANCH_NAME}")
version = pom.version
// replace sonar-project.properties values
Properties props = new Properties()
File propsFile = new File("${env.WORKSPACE}/sonar-project.properties")
props.load(propsFile.newDataInputStream())
props.setProperty('sonar.branch', "${env.BRANCH_NAME}")
props.setProperty('sonar.projectVersion', version)
@prikkeldraad
prikkeldraad / Jenkinsfile_stage_versions.groovy
Created May 8, 2018 06:50
Jenkins file to set versions with Maven
// determine version based on git branch name, supply pom info first
@NonCPS
def getVersion = { Class pom ->
def matches = (env.BRANCH_NAME =~ /^(master|release|develop|feature)\/?(.*)/)
try {
if (matches[0][1] in ['release', 'develop']) {
if (pom.version != matches[0][2]) {
error "Branch version ${matches[0][2]} is not the same as pom version ${pom.version}"
}
@prikkeldraad
prikkeldraad / Jenkinsfile_stage_pom.groovy
Last active August 13, 2018 07:38
Jenkinsfile stage to set version in poms with maven
stage('Info') {
// read info from pom (see: http://maven.apache.org/components/ref/3.3.9/maven-model/apidocs/org/apache/maven/model/Model.html)
pom = readMavenPom file: 'pom.xml'
printf("Version: %s", pom.version)
// list modules
printf ("Modules: %s", pom.getModules().join(","))
// set version explicit in maven pom, always add build number
// format of version should be: <name>-x.y.x-<branch?>-<build>
@prikkeldraad
prikkeldraad / gist:07278ef511df1e055a16d6de6d940af2
Last active May 9, 2017 10:58
nginx for nexus2.14 / 3.x url conversion
proxy_send_timeout 120;
proxy_read_timeout 300;
proxy_buffering off;
# keepalive_timeout 5 5;
tcp_nodelay on;
ssl_password_file /etc/ssl/global.pass;
server {
@prikkeldraad
prikkeldraad / zapp.py
Created April 24, 2017 11:50
Python wrapper for Bamboo to run OWASP ZAP
#!/bin/env python
import argparse
import subprocess
from lxml import etree
from pprint import pprint
# parse command line parameters
parser = argparse.ArgumentParser()
parser.add_argument('url', help='URL to scan')
parser.add_argument('zap', help='Location of zap executable')
From: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-centos-7
yum install git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
I am working with Oracle VirtualBox on this, so mileage may vary on "real" *nix systems
Get a CentOS 7 (base) from VirtualBoxes.org
yum update (cause it's always old)
Read: MSSQL server (https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-red-hat)
Add the M$ repo of the DB
curl https://packages.microsoft.com/config/rhel/7/mssql-server.repo > /etc/yum.repos.d/mssql-server.repo
Add the MSSQL server tools (https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools)