0


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?

2 Answers 2

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}'
Sign up to request clarification or add additional context in comments.

2 Comments

i knew that already, but i want to use the username as a variable in the pipeline script
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
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.