Dry Goods | JENKINS2.0 Pipeline Framework (IPipeline)--A practical approach to optimization (II.)

Source: Internet
Author: User
Tags getmessage docker swarm

Click on the "ZTE developer community" above to focus on our

Read a first-line developer's original article every day.

Problem description

After the introduction of the Jenkins2.0 ipipeline framework (plll Library), the project CI system should be said to have promoted a lot of happiness, one of the important aspects is that the framework has provided users with the basic format for reporting and mailing, showing intuitive and efficient.


An example of the basic format of a typical report and message is shown in the following illustration:

As you can see from the diagram, the overview information for each step is formatted to display, execute reports and links, product library reports and links, and run time at a glance.


But precisely because the PLLL library has formatted reports and message styles, users cannot expand the content of reports and message presentations based on the basic reporting style. This is not convenient in cases where the results of several use case tests for this project need to be attached to reports and messages


So we decided to make the report and message presentation extensible, so that the user could add other data and display it in addition to the basic reporting format, which we call the Quickreport for the quick report.


With this problem, we have made corresponding optimization and practice to the PLLL library. Optimization Practice


Optimize PLLL Library Source code, add Quickreport function:

def quickreportcontent = ""

try {

Foreachfunctions {Context->

if (Context.args.param.quick_report) {

for (int i=0; i<context.args.param.quick_report.size (); i++)

{

def Context.args.param.quick_report[i]

if (report.report_dir && report.report_file && report.report_name

&& (report.report_always | | context.message== ')) {

def quickreportfile = Report.report_dir + "/" + Report.report_file

Quickreportcontent = ReadFile Quickreportfile

Quickreportcontent = "<p> </p> <p> </p>

echo "Quickreport content is:" + quickreportcontent

}

}

}

}

}

catch (Exception ex) {

Echo Ex.getmessage ()

GetData (). result= ' Failure '

GetData (). message+= "[ERROR] Publishreportall ${ex.getmessage ()} \ n"

}

html = html + quickreportcontent

Use examples:


For the user, simply match the Quick_report parameter in the Param parameter list of the Plll interface to indicate the parameters such as the report content and file name that need to be extended, and the user's extension will be added to the report or message, and the sample code is as follows:

Plll. Test ("Check_xxx_case", "Case Check", [

Run_dir: "${verifyscriptpath}/${runsubpath}",

run_execute:{run "${cmd}"},

Verify_dir: "${->env." output_path}/",

Verify_after:tmp_move_shell_name,

Verify_execute:tmp_verify_shell_log_name,

param:[

Report_file:[[report_dir: "${->env." output_path}/", Report_file:" ${publishlogname} ", Report_name:" Case Check _report ", Report_always:true]],

Quick_report:[[report_dir: "${->env." output_path}/", Report_file:" ${quickreportname} ", Report_name:" Case Check _quick_report ", Report_always:true]

]

]);

As seen by the code, we have configured the directory in the Quick_report's parameter list, the report file name, and the name of the report, and the framework automatically attaches the user-defined report to the original base table and splits it in a green split line.


Effect Display:

For example, for this project, each time a test task is called a message case test report needs to be visually presented to the user, without having to let the user click on the link to view it, so we can extend it as quickreport to the Mail and Jenkins Summary report:


Jenkins Summary Report as follows, the user-defined table has been expanded below, as shown in the following figure:

The same message is also extended to display, as shown in the following illustration:

Promotion Suggestions


The relevant optimization improvement points in this article can be extended to projects that need to customize and extend the original IPipeline framework report and message format.


The next article will be released tomorrow, mainly introduce the MERGECI mechanism, please look forward to ~


Expand your Reading

Preliminary study on dry |docker swarm cluster

Dry Goods | JENKINS2.0 Pipeline Framework (IPipeline) Optimization of Practice (I.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.