Skip to content

Instantly share code, notes, and snippets.

@samratshaw
samratshaw / getJenkinsApiToken curl
Created September 18, 2018 15:29
Medium: Curl for retrieving Jenkins API Token
curl --silent --basic http://<username>:<password>@<jenkins-url>/me/configure | hxselect '#apiToken' | sed 's/.*value="\([^"]*\)".*/\1\n/g'
@samratshaw
samratshaw / Jenkinsfile
Created September 27, 2018 10:22
Medium: Jenkinsfile to accept build parameters (Sample shows sending email parameters)
node('linux') {
properties([[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
parameters(
[
string(defaultValue: "", description: 'To', name: 'to'),
string(defaultValue: "", description: 'Cc', name: 'cc'),
string(defaultValue: "", description: 'Subject', name: 'subject'),
string(defaultValue: "", description: 'Body', name: 'body'),
string(defaultValue: "", description: 'From', name: 'from'),
]
@samratshaw
samratshaw / sendEmail.ts
Created September 27, 2018 10:35
Medium: Invoke Jenkins Build With Parameters Programmatically
import * as fs from 'fs';
import * as queryString from 'query-string';
import * as request from 'request';
import config from '../config/index';
/**************************************************/
// Interface Declaration
/**************************************************/
export interface ISendEmailDetails {
to: string[]; // List of emailId's
@samratshaw
samratshaw / merge-checker.sh
Last active November 18, 2020 17:51
Compare two branches for multiple repositories
#!/bin/bash
# {
# "repositories": [
# {
# "url": "https://xxx.git",
# "baseBranch": "origin/release/1.x",
# "targetBranch": "origin/daily"
# },
# {