Jenkins console output unrecognizable text. Why? - jenkins

enter image description here
After starting the autotests, their names are displayed incorrectly in the console. What could it be related to? Locally via vs code the names are displayed correctly
enter image description here
I want to understand if it's because of playwright or if it's because of jenkins

Related

Set global description for Jenkins instance

Using Jenkins we would like to set this global description by default. We have used groovy scripts to set other global variables but I'm struggling to find what methods / classes I need to call in order to set this description for our Jenkins instance. I see many description plugins for builds but this is instead the description you see on the Jenkins homepage (not per build). In the image below I clicked "Edit description" and then typed "test" in the box and pressed save.
That's the workflow we'd like to automate using Jenkins groovy code :)
Thanks!
The description that is shown in your image, is not a global Jenkins description but rather the description of the current view you are looking on - in this case the All view. If you switch to another view it will change.
To modify this via groovy code you need to modify the description of the view by its name:
Jenkins.instance.getView('all').setDescription("My New Description")
If you do want a global message that will appear always regardless of the selected view you can use the System Message option (configurable via the Configure System menu):
This message will be displayed at the top of the Jenkins main page.
This can be useful for posting notifications to your users
To update the system message via groovy code you can use the flowing:
Jenkins.instance.setSystemMessage("My System Message")

How do you display a clickable repo link in the Jenkins output?

In my Jenkins Console logs it says:
Obtained jenkins/some.jenkinsfile from git ssh://mygitserver.myorg.com/my/git/repo.git
so I have to copy / paste / edit to get that repo then click about to the Jenkinsfile in your browser.
When you're doing this multiple times every day it becomes a major headache.
Is there anyway to get a simple clickable link?
I would suggest crafting an output that would then become clickable. i.e. declare the link then specify the file using a variable.
script { println("https://yourRepoUrl.com/jenkins/${downloadFile}) }
Alternatively, you could download the file from within the pipeline. See here for details

Jenkins : Build Time and timestamps

My jobs build at the same time every day.
But I don’t know why some job took a long time.
Does anyone know why this happens?
enter image description here
After that I thought of looking at the full log output from the console.
Confirm when something went wrong
But when clicking full log, not all logs are listed.
enter image description here
Jenkins stored log does not show time.
Or is there any way to read timestamps file?

How to display a hyperlink in hudson/jenkins build output console

How do I display a hyperlink (weblink) in hudson/jenkins build output console?
What I'm trying to achieve is, during a hudson/jenkins build based on certain condition, I would like to display a hyperlink.
When a user click on that link, it should open a new browser window and show the page.
Is there a plugin to do this? Any suggestions please?
When using a (system) groovy script or Jenkins job pipeline (without sandbox) you may want to try e.g.:
import hudson.console.ModelHyperlinkNote
println hudson.console.ModelHyperlinkNote.encodeTo('http://example.com', 'example')
Please find the full API of hudson.console.ModelHyperlinkNote here:
http://javadoc.jenkins-ci.org/hudson/console/ModelHyperlinkNote.html
If you enter, for example:
echo 'http://example.com'
in a Build step Execute shell → Command the address will be hyperlinked in the Console Output, though not with target="_blank". But middle-clicking on it opens it in a new tab or window – depending on your browser preferences.

How can I report the test results from a TestNG/Maven/Jenkins tests, via Email and attach screenshot?

I have some SeleniumWebdriver/TestNG/Maven/Java continuous integration tests, that I run in Jenkins.
Every time a test fails, a screenshot of the error is created.
How can I configure Jenkins to send an email to certain people and attach the screenshot upon failure?
The screenshot is located in this directory:
/mnt/www/jenkins/jobs/Integration tests/workspace/target/surefire-reports/
and its name is generated as a combination of a timestamp and the error that has occured, like this:
2013-7-6-12-1-30-UnabletolocateelementmethodlinktextselectorApprove.jpg
Screenshots arent automatically deleted, so there could be quite a few screenshots in that dir.
So, how can I make Jenkins send me the report with the screenshot attached?
OR Can I make TestNG do that? How?
Actually, no need to work with Jenkins, it can be done within the code of the test itself.
Generate the screenshot as described here:
Selenium Webdriver/TestNG/Maven/Xvfb - take screenshot on fail?
then install the Java Mail API and a SMTP mailer service on your computer and make your code send email with the screenshot as an attachment upon failure.

Resources