Skip to content

Instantly share code, notes, and snippets.

@vadikgo
vadikgo / bulldog.txt
Created January 24, 2020 08:37
Build on windows docker
C:\Users\vad\dev\gpt-2>docker build --tag gpt-2 -f Dockerfile.cpu .
Sending build context to Docker daemon 4.712MB
Step 1/7 : FROM tensorflow/tensorflow:1.12.0-py3
---> 39bcb324db83
Step 2/7 : ENV LANG=C.UTF-8
---> Using cache
---> 6f94b464e517
Step 3/7 : RUN mkdir /gpt-2
---> Using cache
---> 9cb7e44243ba
@vadikgo
vadikgo / workspace_wipe.groovy
Last active September 16, 2019 11:45
Wipe workspace folder on Jenkins master server
def isBuilding(job) {
for (comp in Jenkins.instance.computers) {
for (ex in comp.executors){
if (ex.isBusy() && (ex.getCurrentExecutable().getParent().getOwnerTask().getName() == job.name)) {
return true
}
}
}
return false
@vadikgo
vadikgo / ansible_portable
Created September 10, 2019 19:00
Build portable ansible virtualenv
#!/bin/bash
set -e
ansible_tool() {
ver=$1
tag=$(echo ${ver} | awk -F . '{print $1$2}')
virtualenv ansible${tag}
source ansible${tag}/bin/activate
python -m pip install ansible==${ver} \
lxml xmltodict python_ntlm docker pywinrm==0.2.2 pyzabbix requests-credssp jmespath \
@vadikgo
vadikgo / clean-pods
Created March 18, 2019 11:11
Clean failed kubernetes pod
#!/bin/bash
export PATH=$PATH:/usr/local/bin
namespaces=(jenkins worker gitlab)
for ns in "${namespaces[@]}"
do
kubectl get pods -n "${ns}" --show-all --no-headers=true --field-selector=status.phase=Failed -o=custom-columns=NAME:.metadata.name | xargs -I {} -P 8 kubectl delete pod -n "${ns}" {}
kubectl get pods -n "${ns}" --show-all --no-headers=true --field-selector=status.phase=Succeeded -o=custom-columns=NAME:.metadata.name | xargs -I {} -P 8 kubectl delete pod -n "${ns}" {}
kubectl get pods -n "${ns}" --show-all --no-headers=true -o json | jq -r '.items[] | select([.status.containerStatuses[] | select(.state.terminated.reason == "Error")] | length == 1) | .metadata.name' | xargs -I {} -P 8 kubectl delete pod -n "${ns}" {}
@vadikgo
vadikgo / install
Last active May 29, 2022 09:58
Install python 3.7 in CentOS 7
#!/bin/sh
yum install gcc openssl-devel bzip2-devel libffi-devel make -y
curl https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz | tar -xzpvf -
mkdir -p /opt/python3
cd Python-3.7.2
./configure --enable-optimizations --prefix=/opt/python3
make altinstall
/opt/python3/bin/python3.7 --version
@vadikgo
vadikgo / generate.sh
Last active February 21, 2019 06:21
Generate k8s user access key
#!/bin/bash
set -ex
[[ -z $3 ]] && exit 1
#user="worker"
#lb_url="https://k8s-master.example.com:6443"
#master_host="root@master1"
user=$1
lb_url=$2
@vadikgo
vadikgo / nexus_version.groovy
Created November 12, 2018 10:48
Nexus artifacts Jenkins dropdown demo
node('linux') {
def ver
stage ('Stage 1') {
withCredentials([usernamePassword(credentialsId: 'nexus_user_cred', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
def versions = getVersionId('http://nexus.example.com:8081/nexus/service/local', "${USERNAME}", "${PASSWORD}",'distrib', 'test1')
ver = input message: 'Get version',
parameters: [choice(choices: versions, description: '', name: 'versions')]
file_name = ver + '.zip'
getNexusFile(file_name, "${USERNAME}", "${PASSWORD}", 'http://nexus.example.com:8081/nexus/service/local', 'loans.car', ver, 'zip', 'test_elease', 'distrib', '')
}
@vadikgo
vadikgo / jenkins_update_center_gav.yml
Last active November 9, 2018 20:57
Get Jenkins plugin gav
---
- hosts: localhost
gather_facts: false
connection: local
tasks:
- name: get update-center.json
get_url:
url: 'https://updates.jenkins.io/update-center.json'
dest: ./update-center.json
- name: strip update-center
@vadikgo
vadikgo / jenkins-plugins.yml
Created November 8, 2018 14:31
Plugins list to compare
jenkins_plugins:
- name: ace-editor
version: '1.1'
- name: active-directory
version: '2.9'
- name: ali-jenkins-plugin
version: '2.2.57-1123.0'
- name: allure-jenkins-plugin
version: '2.27.0'
- name: analysis-core
@vadikgo
vadikgo / compare-jenkins-plugins.yml
Last active November 9, 2018 07:09
Compare jenkins plugins
- name: Compare plugins
hosts: jenkins[0]
gather_facts: false
#connection: local
tasks:
- name: Load active plugins list from Jenkins
jenkins_script:
script: |
import groovy.json.JsonOutput
def plugins = []