Tuesday, 18 August 2020

Further fun with the Jenkins Script "sandbox"

 I'm helping a colleague get to grips with Groovy scripting in Jenkins, and had introduced him to the "Sandbox"

I also wanted to provide some file I/O examples, as per the following: -


File greetingsFile = new File('/tmp/greetings.txt')

greetingsFile.write "Hello World!\n"


greetingsText = greetingsFile.getText('UTF-8')

println("Greeting is " + greetingsText)


All that does is (a) create a file containing the immoral phrase "Hello World!" and (b) read the content of the newly created file into a variable called greetingsText and (c) output the message to the console.


No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...