Skip to content

Instantly share code, notes, and snippets.

@jimklo
Created May 14, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimklo/7593c68ef2c51cb1a5c951e061efd612 to your computer and use it in GitHub Desktop.
Save jimklo/7593c68ef2c51cb1a5c951e061efd612 to your computer and use it in GitHub Desktop.
Issue with running this Pipeline Shared Library
class GitTool extends StepsBase {
def GitTool(steps) {
super(steps)
}
def runSh(script, returnStdout = false) {
def output = steps.sh(script: script, returnStdout: returnStdout)
return output.toString()
}
@NonCPS
def commitGitChanges(String path, String message, String gitEmail='sunflower@sunflower-build-bot.local', String gitName='sunflower-build-bot') {
def git_cmd
steps.dir(path) {
runSh("git config --local user.email '${gitEmail}'".toString())
runSh("git config --local user.name '${gitName}'".toString())
runSh('git add -A')
git_cmd = runSh("git commit --message '${message}'".toString(), true)
}
return git_cmd
}
}
class StepsBase implements Serializable{
def steps
StepsBase(steps=null) {
this.steps = steps
}
def log(message) {
if (this.steps) {
this.steps.println("${message}".toString())
} else {
println(message)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment