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
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/
Step 1: Go the the “Settings” of your Jenkins project. Step 2: Go to the “Build Triggers” section. Step 3: Under the “Build when a change is pushed to Gitlab” checkbox, click the “advanced” button. Step 4: Click the “Generate” button under the “Secret Token” field.
Easily and quickly configurable: Jenkins is easily integrated with GitLab Enterprise Edition, right from your project's integrations settings. Once you've enabled the service to configure GitLab's authentication with your Jenkins server, and Jenkins knows how to interact with GitLab, it's ready to use, out-of-the-box.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With