Last active
September 20, 2019 08:08
-
-
Save swsnr/4c11a5e3ce8912296bbf94897ea28c17 to your computer and use it in GitHub Desktop.
SBT Jenkins Pipeline Step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/groovy | |
/** | |
* Run SBT via sh with the given arguments. | |
* | |
* Injects a file pointed to by $NEXUS_CREDENTIALS env var for publishing credentials. | |
* Use the Credentials Jenkins plugin to manage these credentials in Jenkins and inject | |
* them into a build. | |
* | |
* @param sbtArgs Arguments for SBT | |
* @return | |
*/ | |
def call(String sbtArgs) { | |
// Extract the launcher to file system | |
def sbt = "${pwd tmp: true}/sbt" | |
// A copy of <https://github.com/paulp/sbt-extras/blob/master/sbt> included as library resource | |
def launcher = libraryResource 'com/acme/sbt-extras/sbt' | |
writeFile file: sbt, text: launcher | |
def inputrc = "${pwd tmp: true}/inputrc" | |
// Get hold of Nexus credentials | |
withCredentials([file(credentialsId: 'sbt-nexus-credentials', variable: 'NEXUS_CREDENTIALS')]) { | |
def defaultArgs = [ | |
// Make jline use an empty inputrc to fix "unable to bind key" | |
// issues in SBT | |
"'-Djline.inputrc=${inputrc}'", | |
// Disable formatting, doesn't look well in Jenkins build console | |
'-Dsbt.log.noformat=true', | |
// Credentials for booting SBT from our nexus (note: we deliberately quote here because | |
// NEXUS_CREDENTIALS is an environment variable not a groovy variable)… | |
'"-Dsbt.boot.credentials=${NEXUS_CREDENTIALS}"', | |
// …and for SBT the actual SBT build | |
'\'set Global / credentials += Credentials(file(sys.env("NEXUS_CREDENTIALS")))\'', | |
] | |
sh label: 'sbt', script: "bash ${sbt} ${defaultArgs.join(' ')} ${sbtArgs}" | |
} | |
} |
Author
swsnr
commented
Sep 19, 2019
via email
I know but as far as I can see it doesn’t come as a single script, does it?
The sbt-extras script runs standalone and downloads SBT automatically so it’s really easy to use 🙂
… Am 18.09.2019 um 06:47 schrieb Nepomuk Seiler ***@***.***>:
There's now an official sbt launch script: https://github.com/sbt/sbt-launcher-package
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Saw that too 🤗 and deleted my command instantly 😹
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment