Tuesday, April 12, 2016

Jenkins: Link between Stacktrace and GitLab

Leave a Comment

We use Jenkins and GitLab in our company. We use py.test to create the XML output for Jenkins which gets rendered by the jUnit Jenkins Plugin.

The stacktraces of exceptions are pure ascii up to now. It would be really great if we could hook into Jenkins somehow and show hyperlinks to our gitlab server instead of a html pre block.

In our case we it would be enough to filter the every line of the test output and use a regular expression on it....

Example output of the Jenkins jUnit Plugin:

File "/home/modwork_ems_d66/src/foo/foo/utils/testutils.py", line 975, in wrapped     return fn(*args, **kwargs) File "/home/modwork_ems_d66/src/foo/foo/tests/FooTest.py", line 641, in test_empty_models_if_unused     models)) 

I want a hyperlink to the server hosting the git repo of "foo". In our case this would be "https://source/repos/foo/files/master/foo/foo/tests/FooTest.py"

How to get this done? I know how to use regular expressions. The question is how to hook the regex into jenkins.

Here is a screenshot to visualize it enter image description here

I want to this link on the TestReport of a single test. The URL pattern of these pages:

https://jenkins/job/ci_foo_bar/lastCompletedBuild/testReport/src.myapp.myapp.tests.test_tree/TestCase/test_something/ 

1 Answers

Answers 1

If you can acquire exception output after testing process you can implement a parser which prepare a simple html report for you as a build-step.

A a simplest way you can implement just a regular expression with sed like

sed -e 's@"/home/modwork_ems_d66/src\(.*\?\)"@<a href="https://source/repos/foo/files/master\1">\1</a>@' exceptions.txt 

which operates on the exception file.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment