Skip to content

Instantly share code, notes, and snippets.

View ivan-pinatti's full-sized avatar
👨‍💻

Ivan Pinatti ivan-pinatti

👨‍💻
View GitHub Profile
@ivan-pinatti
ivan-pinatti / sync-music-library-to-android.bash
Last active September 11, 2020 17:42
Sync a local music library to an Android device through SSH using RSYNC
#!/usr/bin/env bash
: ' Script to sync a music library from local machine to an Android device
through a SSH connection using rsync and checking files using size only
method.
I do recommend SSHelper as a SSH server for Android devices, you can
download and install it from here:
https://play.google.com/store/apps/details?id=com.arachnoid.sshelper
@ivan-pinatti
ivan-pinatti / disk-monitor.sh
Last active October 26, 2017 20:44
Script that collects disk space from Linux and pushes a message to Slack with the results, if it is an alert it will also mention @channel.
#!/usr/bin/env bash
: ' Script that collects disk space from Linux and pushes a message to Slack with
the results, if it is an alert it will also mention @channel.
'
# check if debug flag is set
if [ "${DEBUG}" = true ]; then
@ivan-pinatti
ivan-pinatti / jenkins-disable-cli.groovy
Last active June 27, 2019 15:06
Jenkins - Disable CLI via groovy script - #jenkins #groovy
#!groovy
//
// only works on Jenkins version < 2.165
//
// imports
import jenkins.model.Jenkins
// get Jenkins instance
@ivan-pinatti
ivan-pinatti / jenkins-disable-insecure-protocols.groovy
Last active February 4, 2018 01:30
Jenkins - Disable old insecure protocols via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
import jenkins.security.s2m.*
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
// define protocols
@ivan-pinatti
ivan-pinatti / jenkins-set-default-crumb-issuer.groovy
Last active June 8, 2021 13:47
Jenkins - Set default crumb issuer via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
import hudson.security.csrf.DefaultCrumbIssuer
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
// set default crumb issuer
@ivan-pinatti
ivan-pinatti / jenkins-set-url-and-email.groovy
Last active September 22, 2023 20:20
Jenkins - Set URL and email via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
import jenkins.model.JenkinsLocationConfiguration
// parameters
def jenkinsParameters = [
email: 'Jenkins Admin <[email protected]>',
url: 'https://ci.jenkins.com:8083/'
@ivan-pinatti
ivan-pinatti / jenkins-set-number-of-executors.groovy
Last active October 31, 2019 20:27
Jenkins - Set number of executors via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
// parameter
Integer numberOfExecutors = 2
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
@ivan-pinatti
ivan-pinatti / jenkins-set-git-plugin-global-parameters.groovy
Last active February 4, 2018 01:29
Jenkins - Set Git plugin global parameters via groovy script - #jenkins #groovy #git
#!groovy
// imports
import jenkins.model.Jenkins
// parameters
def gitParameters = [
globalConfigEmail: '[email protected]',
globalConfigName: 'Jenkins CI'
]
@ivan-pinatti
ivan-pinatti / jenkins-set-github-oauth-plugin.groovy
Last active February 4, 2018 01:29
Jenkins - Set Gihub Oauth plugin parameters via groovy script - #jenkins #groovy #github #oauth
#!groovy
// imports
import hudson.security.AuthorizationStrategy
import hudson.security.SecurityRealm
import jenkins.model.Jenkins
import org.jenkinsci.plugins.GithubAuthorizationStrategy
import org.jenkinsci.plugins.GithubSecurityRealm
// parameters
@ivan-pinatti
ivan-pinatti / jenkins-add-ssh-keypair-with-password-credential.groovy
Last active June 21, 2023 11:46
Jenkins - Add SSH keypair with password credential via groovy script - #jenkins #groovy #ssh #credential
#!groovy
// imports
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.Domain
import com.cloudbees.plugins.credentials.impl.*
import hudson.util.Secret
import java.nio.file.Files