node{
sh"""
mkdir('foo')
"""
dir ('foo') {
git branch: "<ref spec>", changelog: false, poll: false, url: '<clone url>'
......
}
}
Jenkins World
Friday, 17 July 2020
In Jenkins, how to checkout a project into a specific directory (using GIT)
Thursday, 16 July 2020
passing variable to bash script in a jenkins pipeline job
def UNIQUE = sh(returnStdout: true, script: 'uuidgen').trim()
from : https://stackoverflow.com/questions/40323490/passing-variable-to-bash-script-in-a-jenkins-pipeline-job
from : https://stackoverflow.com/questions/40323490/passing-variable-to-bash-script-in-a-jenkins-pipeline-job
Sunday, 28 June 2020
How do I make curl ignore the proxy?
curl --noproxy "*" http://www.stackoverflow.com
vi ~/.curlrc
noproxy=*
proxy=yourproxy.com:8080
Replace one substring for another string in shell script
#!/bin/bash
firstString="I love Suzi and Marry"
secondString="Sara"
echo "${firstString/Suzi/$secondString}"
# prints 'I love Sara and Marry'
EXAMPLE 2:
URL="http://hostname/project/branches/Old_Branch/package"
SRC="Old_Branch"
REP="New_Branch"
echo "${URL/$SRC/$REP}"
Loop through an array of strings in Bash?
## declare an array variable
declare -a arr=("element1" "element2" "element3")
## now loop through the above array
for i in "${arr[@]}"
do
echo "$i"
# or do whatever with individual element of the array
done
# You can access them using echo "${arr[0]}", "${arr[1]}" also
In Bash, how can I check if a string begins with some value?
This snippet on the Advanced Bash Scripting Guide says:
# The == comparison operator behaves differently within a double-brackets
# test than within single brackets.
[[ $a == z* ]] # True if $a starts with a "z" (wildcard matching).
[[ $a == "z*" ]] # True if $a is equal to z* (literal matching).
string='My long string'
if [[ $string == *"My long"* ]]; then
echo "It's there!"
fi
Subscribe to:
Posts (Atom)