Skip to content

Instantly share code, notes, and snippets.

@leonowski
leonowski / gist:332498b12365e730ef9c0ca17876df0f
Created December 11, 2020 10:43
jenkins script to remove some lockable resources
def manager = org.jenkins.plugins.lockableresources.LockableResourcesManager.get()
def resources = manager.getResources().findAll {
(!it.locked) && (
it.name.contains("PR-") ||
it.name.contains("hotfix-") ||
it.name.contains("feature-")
)
}
resources.each {
println "Removing ${it.name}"
@leonowski
leonowski / gist:4a2c6c5ef6273a974ed3d336c2af8082
Created December 11, 2020 10:42
bash loop through string to find first recurring character
#!/bin/bash
#loop through characters in string taking input from first param
string=${1}
for (( i=0; i<${#string}; i++ )); do
#echo "${string:$i:1}"
for (( x=(($i + 1)); x<${#string}; x++ )); do
#echo XXX- "${string:$x:1}"
if [[ "${string:$i:1}" == "${string:$x:1}" ]]
then
@leonowski
leonowski / systemd-prblm.service
Created December 8, 2020 21:41 — forked from nickjacob/systemd-prblm.service
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"
### Keybase proof
I hereby claim:
* I am leonowski on github.
* I am leonowski (https://keybase.io/leonowski) on keybase.
* I have a public key ASBKdnQmZAKpbC7aouLlyHhnm4O6j2b3S63HZvZ-Rft6Vwo
To claim this, I am signing this object: