Skip to content

Instantly share code, notes, and snippets.

View KondaReddyR's full-sized avatar

Konda Reddy KondaReddyR

View GitHub Profile
@KondaReddyR
KondaReddyR / jq to filter by value.md
Created August 1, 2019 19:24 — forked from ipbastola/jq to filter by value.md
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@KondaReddyR
KondaReddyR / PipelineJob.groovy
Created April 22, 2019 12:26
Groovy Script to create Pipeline jobs
import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.job.WorkflowJob
import org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition
import hudson.plugins.git.GitSCM
WorkflowJob job = Jenkins.instance.createProject(WorkflowJob, 'KondaReddyR/java-project')
def definition = new CpsScmFlowDefinition(new GitSCM('[email protected]:KondaReddyR/java-project.git'), 'resources/housekeeping/install_python_packages.groovy')
definition.scm.userRemoteConfigs[0].credentialsId = 'GITHUB_SSH_KEY'
@KondaReddyR
KondaReddyR / orgs.md
Created April 7, 2019 15:42
Github Api V4 Graphql Fetch Orgs
orgs=`curl -H "Authorization: bearer $GH_TOKEN" -X POST -d "  { \"query\": \"query { user(login: "KondaReddyR") { organizations(first: 10) { edges { node {  login} } } } }\"  }  " https://api.github.com/graphql | jq -c  .`


for org in $(echo "${orgs}" | jq -r '.data.user.organizations.edges[] | .node.login '); do
  echo $org
done
@KondaReddyR
KondaReddyR / jenkins_plugins_sort.groovy
Created April 4, 2019 18:40
Jenkins Script Plugins sorted
ArrayList pluginsList = Jenkins.instance.pluginManager.plugins
pluginsList.sort{ it.shortName }.each{
print it.shortName
}
@KondaReddyR
KondaReddyR / Jenkinsfile.groovy
Last active March 29, 2019 03:35
Trigger Freestyles
pipeline{
agent none
parameters {
booleanParam(name: 'EXTRACT_DATA', defaultValue: true, description: '')
string(name: 'RECORDS', defaultValue: '100', description: '')
choice(name: 'DB', choices: ['one', 'two', 'three'], description: '')
}
options {
disableConcurrentBuilds()
timeout(time: 1, unit: 'HOURS')
@KondaReddyR
KondaReddyR / ssh-tunnel.sh
Created July 11, 2018 20:18
SSH Tunneling to Access Restricted Servers and Browse Securely
ssh -L local_port:remote_address:remote_port [email protected]
@KondaReddyR
KondaReddyR / create-certs.sh
Created June 7, 2018 13:11 — forked from sethvargo/create-certs.sh
Use openssl to create an x509 self-signed certificate authority (CA), certificate signing request (CSR), and resulting private key with IP SAN and DNS SAN
# Define where to store the generated certs and metadata.
DIR="$(pwd)/tls"
# Optional: Ensure the target directory exists and is empty.
rm -rf "${DIR}"
mkdir -p "${DIR}"
# Create the openssl configuration file. This is used for both generating
# the certificate as well as for specifying the extensions. It aims in favor
# of automation, so the DN is encoding and not prompted.
@KondaReddyR
KondaReddyR / jenkins-aws.txt
Created August 7, 2017 01:57
Disaster-proof Jenkins as Swarm service on AWS
From https://docs.docker.com/docker-for-aws/, Deploy Docker Community Edition (CE) for AWS (stable: https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=Docker&templateURL=https://editions-us-east-1.s3.amazonaws.com/aws/stable/Docker.tmpl ) (More Info: http://youtu.be/uWTL8gwzZz4)
export CLUSTER_IP=[...] #Public IP of one of the managers
export CLUSTER_DNS=[...] #DefaultDNSTarget
ssh -i workshop.pem docker@$CLUSTER_IP
docker network create -d overlay proxy
curl -o proxy.yml https://raw.githubusercontent.com/vfarcic/docker-flow-stacks/master/proxy/docker-flow-proxy.yml
@KondaReddyR
KondaReddyR / build.gradle
Created February 3, 2016 01:10 — forked from quidryan/build.gradle
Gradle file to enforce Semantic Versioning.
apply plugin: "java"
repositories {
mavenCentral()
}
dependencies {
compile "org.spockframework:spock-core:0.7-groovy-2.0"
compile "org.codehaus.groovy:groovy-all:1.8.6"
}
@KondaReddyR
KondaReddyR / README.md
Created January 20, 2016 13:01 — forked from hofmannsven/README.md
My simply Git Cheatsheet