Skip to content

Instantly share code, notes, and snippets.

View turboBasic's full-sized avatar
🔮
Focusing

andriy melnyk turboBasic

🔮
Focusing
View GitHub Profile
@turboBasic
turboBasic / inputStringParametersDuringBuild.groovy
Last active September 14, 2020 16:34
Jenkins input string parameters during build time
pipeline {
stages {
stage '1', {
steps {
script {
def userInput = input \
id: 'userInput',
message: 'Enter urls for Upstream and Mirror repositories',
parameters: [
string(
@turboBasic
turboBasic / git-replace-file-with-ignored.sh
Created August 26, 2020 21:04
Replace file tracked by git with ignored version without removing origina #git
#!/bin/sh
# shellcheck disable=SC2039
git-replace-file-with-ignored() {
local fileName=${1?fileName parameter should not be empty}
git config filter.orig.clean "cat %f.orig"
cp "$fileName" "$fileName.orig"
echo "$fileName filter=orig" >> .git/info/attributes
@turboBasic
turboBasic / executeInBash.groovy
Last active September 12, 2021 07:44
Execute complex bash command in Jenkins script console #jenkins #groovy #shell
String DIR = '/data/jenkins/workspace/UISW-C-UI/Daily/c-daily-build'
void executeInBash(String bashCommand) {
java.lang.Process process = ['/bin/bash', '-c', bashCommand].execute()
process.waitFor()
println process.getText()
}
//////
@turboBasic
turboBasic / getFileListFromWorkspace.md
Last active August 9, 2020 08:26
Get all file elements from jenkins job workspace view in browser #jenkins #javascript

Get file listing from web page with Jenkins job workspace

Situation: you see some folder in a job workspace, like on screenshot below and you want to copy all file names with sizes and mtime data.

Jenkins job worspace listing

Solution: paste the following code into your browser console:

@turboBasic
turboBasic / Jenkinsfile.groovy
Last active August 7, 2020 13:32 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes #jenkins #groovy #shell
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER'
// 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"'
// 1
@turboBasic
turboBasic / firefox-places-query.md
Last active November 8, 2021 06:56
Firefox bookmarks with queries to Places db #firefox

Firefox Places database queries

Summary

  • For bookmark queries term is searched within bookmark names and tags. Title is returned if it contains term, tag is returned if only it matches term completely.
@turboBasic
turboBasic / get-contributors-statistics-for-git-repository.sh
Last active June 29, 2020 13:06
Get statistics about contributors to git repository #git
#!/usr/bin/env bash
# 1. Prepare git log
git --no-pager log \
--pretty=format:%H,\"%ad\",\"%aN\",\"%aE\",\"%f\" \
v2.42.1..develop \
> 00-git-log.csv
@turboBasic
turboBasic / process-text-files-in-git-repository.sh
Last active June 29, 2020 04:36
List and process only text files in git repository #git #bash #awk
#!/usr/bin/env bash
# shellcheck disable=SC2016
# List all text files in repo, correctly process file names with spaces, tabs and line feeds
textFiles="$(
git grep --null -I --files-with-matches '' \
| base64
)"
@turboBasic
turboBasic / quote-bash-command-in-cmake.cmake
Last active May 13, 2020 13:13
How to quote bash command with redirection and process substitution in CMake #cmake #bash
function(printCommand THE_COMMAND)
message("command: " ${THE_COMMAND})
foreach(item ${ARGN})
string(STRIP ${item} stripped_item)
message(" ‘${stripped_item}’")
endforeach()
endfunction()
set(EXE_FILE "printf ")
@turboBasic
turboBasic / shellScript.groovy
Created May 12, 2020 21:15
Simple template for groovy replacement of shell scripts #groovy #scripting
#!/usr/bin/env groovy
void main()
{
def p = 'ps aux'.execute() \
| 'grep code'.execute() \
| ['awk', '{ print $1 }'].execute()
p.waitFor()
println p.text