Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins: Link between Stacktrace and GitLab

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/
like image 512
guettli Avatar asked Nov 25 '13 15:11

guettli


People also ask

How do I trigger GitLab pipeline from Jenkins?

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.

Can Jenkins use GitLab?

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.


1 Answers

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.

like image 164
ScayTrase Avatar answered Oct 18 '22 16:10

ScayTrase