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?
Asked
Active
Viewed 2,014 times
0

mrdlink
- 266
- 4
- 15
2 Answers
2
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}'

lvthillo
- 28,263
- 13
- 94
- 127
-
i knew that already, but i want to use the username as a variable in the pipeline script – mrdlink Jan 16 '18 at 21:50
-
https://stackoverflow.com/questions/36547680/how-to-do-i-get-the-output-of-a-shell-command-executed-using-into-a-variable-fro – lvthillo Jan 16 '18 at 22:14
0
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
}

Ed Randall
- 6,887
- 2
- 50
- 45