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:

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...