Skip to content

Instantly share code, notes, and snippets.

from abc import ABCMeta
import copy
import re
class Parser:
PATTERN = "(\d{2})::(\d{2}):(\d{2})"
def parse(self, time):
@kenych
kenych / GoHTMLParser.py
Last active June 21, 2016 10:17
as GO hasn't yet got an API for pipeline compare feature I have written simple HTML parser for GO pipeline compare to use in JIRA release ticekt creation, infut file is html page and output is list of commits
from HTMLParser import HTMLParser
import sys
class Record:
def __init__(self, a, p):
self.a = a
self.p = p
def __str__(self):
return "a: " + self.a+" p:"+self.p
@kenych
kenych / credentials.ctmpl
Created March 18, 2018 16:36
Jenkins credentials config
common_credentials {
jenkins_service_user = [
username: 'jenkins_service_user',
password: '{{with $secret := secret "secret/jenkins/jenkins_service_user" }}{{ $secret.Data.value }}{{end}}',
description :'for automated jenkins jobs'
]
slack = [
username: '{{with $secret := secret "secret/slack/user" }}{{ $secret.Data.value }}{{end}}',
password: '{{with $secret := secret "secret/slack/pass" }}{{ $secret.Data.value }}{{end}}',
@kenych
kenych / credentials_V2.ctpl
Created March 18, 2018 16:37
Jenkins credentials config, next generation
common_credentials {
exclude{
tyrion-jenkins
}
data{
jenkins_service_user = [
username: 'jenkins_service_user',
password: '{{with $secret := secret "secret/jenkins/jenkins_service_user" }}{{ $secret.Data.value }}{{end}}',
description :'for automated jenkins jobs'
]
@kenych
kenych / entrypoint.sh
Created March 18, 2018 16:38
Jenkins Docker entrypoint
#!/usr/bin/env bash
git clone ssh://git@your_scm_here/jenkins_config_as_code.git ${JENKINS_HOME}/jenkins_config
mv ${JENKINS_HOME}/jenkins_config/*.groovy ${JENKINS_HOME}/init.groovy.d/
consul-template \
-consul-addr "$CONSUL_ADDR" \
-vault-addr "$VAULT_ADDR" \
-config "jenkins_config.hcl" \
-once
@kenych
kenych / jenkins_config.hcl
Created March 18, 2018 16:39
Jenkins consul-temlate config
max_stale = "10m"
retry = "5s"
log_level = "warn"
vault {
renew_token = true
ssl {
enabled = true
verify = false
}
@kenych
kenych / Jenkinsfile
Last active March 18, 2018 18:21
Jenkins config as code job
node {
stage('checkout') {
sh '''
git clone ssh://git@your_scm_here/jenkins_config_as_code.git ${JENKINS_HOME}/jenkins_config
mv ${JENKINS_HOME}/jenkins_config/*.groovy ${JENKINS_HOME}/init.groovy.d/
'''
}
stage('run consul template'){
sh '''
consul-template \
@kenych
kenych / kubernetes.ctmpl
Created March 18, 2018 16:40
kubernetes config consul template
kubernetes {
name = 'Kubernetes'
serverUrl = 'https://kingslanding.westeros.co.uk'
skipTlsVerify = true
namespace = 'kingslanding'
jenkinsUrl = 'http://kingslanding-dev-jenkins.kingslanding.svc.cluster.local'
credentialsId = 'VALYRIAN_STEEL_SECRET'
containerCapStr = '500'
retentionTimeout = 5
connectTimeout = 0
@kenych
kenych / kubernetes.groovy
Created March 18, 2018 16:41
Jenkins Kubernetes plugin config script
import hudson.model.*
import jenkins.model.*
import org.csanchez.jenkins.plugins.kubernetes.*
import org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume
import org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume
//since kubernetes-1.0
//import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar
import org.csanchez.jenkins.plugins.kubernetes.PodEnvVar
//change after testing
ConfigObject conf = new ConfigSlurper().parse(new File(System.getenv("JENKINS_HOME") + '/jenkins_config/kubernetes.txt').text)
@kenych
kenych / scriptApproval.groovy
Created March 18, 2018 16:42
Jenkins scriptApproval plugin config script
import org.jenkinsci.plugins.scriptsecurity.scripts.*
ScriptApproval script = ScriptApproval.get()
ConfigObject conf = new ConfigSlurper().parse(new File(System.getenv("JENKINS_HOME") + '/jenkins_config/scriptApproval.txt').text)
conf.scriptApproval.approvedSignatures.each{ approvedSignature ->
println("checking for new signature ${approvedSignature}")
def found = script.approvedSignatures.find { it == approvedSignature }
if (!found){
println("Approving signature ${approvedSignature}")
script.approveSignature(approvedSignature)
}