Skip to content

Instantly share code, notes, and snippets.

View xiaojueguan's full-sized avatar
💭
I may be slow to respond.

XiaojueGuan xiaojueguan

💭
I may be slow to respond.
View GitHub Profile
#!/bin/bash
pmt='apt'
pkgs=('python3-pip')
# Check the distribution
if [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ -n "$PRETTY_NAME" ]]; then
echo "Distribution: $PRETTY_NAME"
#!/bin/bash
version=$1
service=$2
function print_help()
{
echo "Usage:"
echo "./installFrp.sh version serviceName"
echo "example ./installFrp.sh 0.49.0 frps"
wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
chmod +x ubuntu-mainline-kernel.sh
mv ubuntu-mainline-kernel.sh /usr/local/bin/
# search kernel match 5
ubuntu-mainline-kernel.sh -r 5
# install kernel v5.15.74
ubuntu-mainline-kernel.sh -i v5.15.74
@xiaojueguan
xiaojueguan / jenkins_script_create_credentials_from_json_str.groovy
Created October 11, 2022 05:25
jenkins script create credentials with json string
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import groovy.json.JsonSlurper
def createCredentialsByJsonStr(credsJsonStr) {
jsonSlurper = new JsonSlurper()
creds = jsonSlurper.parseText(credsJsonStr)
creds.each{cred->
@xiaojueguan
xiaojueguan / jenkins_script_get_credentials_to_json_string.groovy
Created October 11, 2022 05:13
jenkins script get credentials to json string
import groovy.json.JsonOutput
def get_credentials() {
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null
)
credentials = []
for(c in creds) {
@xiaojueguan
xiaojueguan / jenkins_script_create_ssh_slaves.groovy
Created October 11, 2022 05:11
use jenkins script to create ssh slaves from json string
import hudson.model.*
import jenkins.model.*
import hudson.slaves.*
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry
import hudson.plugins.sshslaves.verifiers.*
import groovy.json.JsonSlurper
// https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-masters/create-agent-node-from-groovy
def createSlave(name, homeDir, host, port, credential, nodeDescription, numExecutors, labelString, mode, retentionStrategy) {
// Pick one of the strategies from the comments below this line
@xiaojueguan
xiaojueguan / jenkins_script_get_slaves.groovy
Created October 11, 2022 05:07
script snippt to get slaves from jenkins to json format
import hudson.model.Hudson.instance.slaves
import groovy.json.JsonOutput
def getSlaves() {
slaves = []
hudson.model.Hudson.instance.slaves.each{val->
slave = [:]
slave['name'] = val.getNodeName()
slave['home_dir'] = val.getRemoteFS()
launcher = val.getLauncher()
slave['host'] = launcher.getHost()
@xiaojueguan
xiaojueguan / kubernetes.groovy
Created May 12, 2022 02:15 — forked from kenych/kubernetes.groovy
Jenkins Kubernetes plugin config script
import hudson.model.*
import jenkins.model.*
import org.csanchez.jenkins.plugins.kubernetes.*
import org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.EmptyDirWorkspaceVolume
import org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume
//since kubernetes-1.0
//import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar
import org.csanchez.jenkins.plugins.kubernetes.PodEnvVar
//change after testing
ConfigObject conf = new ConfigSlurper().parse(new File(System.getenv("JENKINS_HOME") + '/jenkins_config/kubernetes.txt').text)