Skip to content

Instantly share code, notes, and snippets.

View CSTDev's full-sized avatar

Carl Taylor CSTDev

View GitHub Profile
@CSTDev
CSTDev / MetricsMiddleware.cs
Last active October 2, 2019 09:37
.Net core middleware for Prometheus metrics on all HTTP requests
using Microsoft.AspNetCore.Http;
using Prometheus;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace mynamespace
{
/// <summary>
/// Middleware component to add a histogram and gague for each HTTP request API endpoint
/// </summary>
@CSTDev
CSTDev / Jenkinsfile
Last active January 9, 2023 04:32
Monorepo Jenkinsfile and groovy script that will create a Multi-branch pipeline for each project that has a Jenkinsfile within your repository, put at the top level of your repo and create a job in Jenkins that runs the Jenkinsfile. Useful for when you're using a monorepo and have multiple Jenkinsfiles in multiple sub directories. This can still…
pipeline {
agent {
label 'docker'
}
stages{
stage('Create jobs'){
steps{
container('docker'){
script{
@CSTDev
CSTDev / auto-increment-version.sh
Last active October 23, 2024 23:42
Script that will find the last Git Tag and increment it. It will only increment when the latest commit does not already have a tag. By default it increments the patch number, you can tell it to change the major or minor versions by adding #major or #minor to the commit message.
#!/bin/bash
#get highest tag number
VERSION=`git describe --abbrev=0 --tags`
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}