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:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...