Skip to content

Instantly share code, notes, and snippets.

@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"
# },
# {
@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 / 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 / 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 / jenkins-token-authentication-api
Created September 12, 2018 14:47
Medium: Curl showing the Jenkins Authentication API (Using Token)
curl -X POST JENKINS_URL/job/JOB_NAME/build \
--user <USER:TOKEN> \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"}]}'
@samratshaw
samratshaw / jenkins-username-password-authentication-api
Created September 12, 2018 14:47
Medium: Curl showing the Jenkins Authentication API (Using Username & Password)
curl -X POST JENKINS_URL/job/JOB_NAME/build \
--user <USER:PASSWORD> \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"}]}'
@samratshaw
samratshaw / getJenkinsApiToken.ts
Last active May 21, 2019 05:57
Medium: Function for retrieving the Jenkins Api Token
import * as request from 'request';
import * as fs from 'fs';
import * as cheerio from 'cheerio';
/**
* Retrieve the Jenkins Api Token.
*/
async function getJenkinsApiToken(): Promise<string> {
return new Promise<string>((resolve, reject) => {
request(
@samratshaw
samratshaw / migration-generate.sh
Created July 30, 2018 09:50
Medium: Sequelize Typescript create migration
cat > ./src/db/migrations/$(date +"%Y%m%d%H%M%S")-$1.ts << EOF
import { QueryInterface, SequelizeStatic } from 'sequelize';
module.exports = {
// tslint:disable-next-line:variable-name
up: async (queryInterface: QueryInterface, Sequelize: SequelizeStatic) => {
// Write migration code here.
},
// tslint:disable-next-line:variable-name
@samratshaw
samratshaw / .sequelizerc
Last active September 26, 2018 02:04
Medium: Sequelize Typescript config
const path = require('path');
module.exports = {
config: path.resolve('src', 'db', 'config.js'),
'models-path': path.resolve('src', 'db', 'models'),
'seeders-path': path.resolve('src', 'db', 'seeders'),
'migrations-path': path.resolve('build-migrations', 'db', 'migrations'),
};
@samratshaw
samratshaw / config.js
Created July 30, 2018 09:47
Medium: Sequelize configuration
const fs = require('fs');
module.exports = {
development: {
url: 'postgres://postgres@localhost:5432/devopsjourney',
dialect: 'postgres',
operatorsAliases: false,
},
production: {
url: process.env.DB_URL,