Skip to content

Instantly share code, notes, and snippets.

@uzilan
Last active June 17, 2019 11:46
Show Gist options
  • Save uzilan/e12f32d6144dc6fce911f21b23a87b75 to your computer and use it in GitHub Desktop.
Save uzilan/e12f32d6144dc6fce911f21b23a87b75 to your computer and use it in GitHub Desktop.
A Jenkins pipeline script to test Exercism solutions in Java and Kotlin
import groovy.io.FileType
def path = ""
def uuid = ""
properties([[$class: "ParametersDefinitionProperty",
parameterDefinitions: [
[$class: "StringParameterDefinition",
description : "Exercise UUID",
name : "UUID"]]]])
stage("Download") {
uuid = env.getEnvironment().get("UUID")
node {
path = sh(script: "exercism download --uuid=$uuid", returnStdout: true).trim()
def split = path.split('/')
def splitLength = split.length
def solutionName = split[splitLength-1]
def track = split[splitLength-2]
def userName = split[splitLength-3]
currentBuild.description = "<a href='https://exercism.io/mentor/solutions/${uuid}'>${userName}s solution for ${solutionName} on ${track}</a>"
}
}
stage("Do not ignore tests") {
node {
if (path.indexOf("kotlin") >-1) {
def dir = new File("${path}/src/test/kotlin")
dir.eachFileRecurse (FileType.FILES) { file ->
file.write(file.text.replaceAll('@Ignore', '//@Ignore'))
}
} else if (path.indexOf("java") >-1) {
def dir = new File("${path}/src/test/java")
dir.eachFileRecurse (FileType.FILES) { file ->
file.write(file.text.replaceAll('@Ignore', '//@Ignore'))
}
}
}
}
stage("Test") {
node {
dir (path) {
sh 'gradle clean test'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment