Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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