DontShaveTheYak has released v0.11.0 of the jenkins-std-lib.
This release is more of a building block to accelerate the development of other features in the future. The classes in the new programs
package are meant to aid in the downloading of executables from remote locations. Right now only HTTP servers are available but in the future other sources can be added like AWS S3, pip or npm.
Checkout the example jobs here, which demonstrates most of the new features. Hosted javadoc documentation is available here.
A sneak peak:
node() {
// Clear the workspace
Path.workspace().deleteContents()
// The version we want to install
final String pinnedVersion = '1.0.0'
TerraformInstaller tfInstaller = new TerraformInstaller(pinnedVersion)
// Install the terraform binary and get back a generic cli tool
CliTool terraform = tfInstaller.install()
// Get the version output for testing
String version = terraform.runCommand('--version').stdOut
// Test that the version is the one we pinned
if (!version.contains(pinnedVersion)) {
error("The version ${pinnedVersion} was not installed.")
}
// Does nothing since it is already installed
tfInstaller.install()
// Install the latest version
tfInstaller = new TerraformInstaller()
terraform = tfInstaller.install()
version = terraform.runCommand('--version').stdOut
// Test the version installed is no longer the pinned version
if (version.contains(pinnedVersion)) {
error('The latest version was not installed.')
}
}
Shameless plug below
If you are using the vscode IDE, then I highly recommend my Jenkins Extension Pack which gives you auto completion and javadoc comments directly in your IDE.