I'm setting up a jenkins ci server. In my pipeline script, where I checkout the latest svn repository of our project, I want to get the user who last committed to the repository, so I can send an email to that specific user if something went wrong.
Is there a function in the svn plugin for jenkins to achieve this?
Add a comment
|
2 Answers
You can use a 'sh' step inside your stage.
This will print the user of the last commit.
svn log -l 1 --quiet | grep "^r" | awk '{print $3}'
2 Comments
kalidali
i knew that already, but i want to use the username as a variable in the pipeline script
Use exception handling to maintain control in the event of an svn failure.
try {
def username = sh(script:'svn log -l 1 --quiet | awk -F\'|\' \'/^r/ { print $2 }\'', returnStdout:true).trim()
} catch (Exception ex) {
println("Unable to fetch svn username: ${ex}")
// use error("message") if you need to fail the build
}