Can I include a link in a Jenkins Node/Agent Description? - jenkins

Our Jenkins process runs quite a few Agent nodes, so we collect information about the agent node when a test runs and upload that to our data services.
What I would like to do is include in the Agent description a link to that data service so users can check out the performance of the node. The Agent page has a "Description" field, which is included in parentheses. Going to the Configuration page allows me to edit the Description contained in the parentheses.
Agent Description
What I don't seem able to do is include a link in that Description field. Jenkins renders it as plain text.
Agent Configuration
I don't need it to be the Description, so is there a way for the Agent page to include a hyperlink?

Related

How can I show an external URL as a build result in Jenkins

Specifically I have a jenkins job that builds and publishes a docker image to our own artifactory instance. What I'm wondering is if it's possible to have the link to that artifactory (or docker hub, or anything else) link in place of the "Last Successful Artifacts" section shown on a build/project page?
For example, if the above image ^^^ had URLs instead of jenkins-archived artifacts. For example the page showing the artifactory page, or something simple like docker pull centos:8.3.2011
As far as i know you cant override the existing links in "Last Successful Artifacts" section, however you have several other options for both FreeStyle and Pipeline jobs:
You can use the Artifactory Plugin to upload your artifacts - it will automatically add links to the artifacts on the build page alongside all relevant Artifactory build info.
You can use the Build Name and Description Setter Plugin to set the build description with the links you want. This description will appear in the upper part of your build page and can include any HTML format you want including icons and links (Safe HTML option must be configured).
You can use the Sidebar Link Plugin to add a customized link to the sidebar menu of your build or project, you can configure the url, link text and the used icon according to your needs.
For using it in pipeline Jobs see the Following Discussion
The Artifactory Plugin is the easiest to use, setting the build description will give you maximum flexibility and the sidebar link is somewhat in the middle of both.

how to use emailext-template in jenkins pipeline to get the template?

There is a good plugin, emailext-template. Basically, I do not have the access to Jenkins-server. It is not convenient to choose the option mentioned in emailext to create the email template.
I dont know how to use this emailext-template plugin to get the template in jenkins-pipeline. There is no guideline in emailext-template. Any documents?
// expected usage in jenkins-pipeline
template_str = emailext-template('template-id')
This can be done in the following way, In case you can deploy jenkins again (if it is done on the cloud), you could create and deploy your email template as part of jenkins installation and configuration.
In case you did not have access to the jenkins server even while deployment, you can just form the html template with the corresponding variables and then use them in the job configuration itself.
The below image shows how the template files are used in jenkins, Instead of the script tag as in the image, you can replace with your own html content so that jenkins will be able to send email with that content.

Deploying jenkins jobs for dynamically created gitlab repos

Setup:
1 Jenkins server and 1 gitlab server that I own
Expected usage:
- We provision repositories for users on gitlab using some scripts when a user signs up with our portal.
- As soon as these users submit some code in the repository, we have to run some junit tests on them and email the users with a the test results in a clean way where they can see the passed and failed results with appropriate links which they can click on to get details of the tests.
Requirements for. jenkins:
1. Ability to send html junit test results with clickable test result links
2. Based on whether the junit test fails or passes, call two different python scripts.
Questions:
1. What is the best way to go about 1 and 2 requirements
2. Should I create a job template and create a job per dynamically created repo or can I use same job to run tests on multiple repos
References :
These were the links we referred.But as a newbie to jenkins couldn't come up with clear solutions.
1.https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin#Email-extplugin-Jellycontent
2.https://gist.github.com/nightspotlight/7cfa6af7c7989857f336f742cdcb443b
3.https://learn2automate.blog/2017/05/19/how-to-set-jenkins-job-status-based-on-test-case-pass/
Send some links in your mail using jenkins is simple
Install https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
Install https://wiki.jenkins.io/display/JENKINS/Build+With+Parameters+Plugin in order to expose a job as link with params
Create some job in jenkins and in the post-build section add editable email notification
[![enter image description here][1]][1]
in In Default Content of editable email notification you must write the email body that will be sent to your users. If your requirement is send a link to allow user to open another jenkins page, you could write the following :
In order to execute python scripts click in this link
http://your-jenkins.com/job/my-job-python/parambuild/?param1=test1&param2=etc
Your mail provider will render this text as html.
Finally you need to create some job with name my-job-python with parameters param1, param2 or whatever. This job will execute your python scripts when user clicks on email links sent by jenkins.

In Jenkins, can I find a job by its display name?

I have a pipeline project with a stage in which a unique identifier is retrieved from an external system and set as the job's display name. I know this identifier to be unique for my whole Jenkins installation, so any search by this key should return exactly zero or one job.
Is there any way I can get a job number/URL (or a list of jobs containing only this one job) given its display name and the project name?
EDIT: I want to find jobs from outside of Jenkins, via user interface or REST API, not from a pipeline.
Take look at Jenkins instance. You can retrieve all Jobs, Folders, ... using the getItem(string)/getItems() methods.
Hardly ideal, but I ended up using the Script Console to list all the jobs, and then used my browsers text search.
Navigate to http://your-jenkins-instance.org.com/script (or Jenkins → Manage Jenkins → Script Console) and run:
Jenkins.instance.getAllItems(AbstractItem.class).each {
println(it.fullName)
};

How to post jenkins job result in jira?

I am running jobs in Jenkins. I want to share the Jenkins job result in Jira. I have tried various plugins but failed to achieve my objective.
https://wiki.jenkins-ci.org/display/JENKINS/JIRA+Plugin
If you also want to use this feature, you need to supply a valid user id/password. If you need the comment only to be visible to a certain JIRA group, e.g. Software Development, enter the groupname.
Now you also need to configure jobs. I figured you might not always have write access to the JIRA (say you have a Jenkins build for one of the Apache commons project that you depend on), so that's why this is optional.

Resources