In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to realize jenkins interface automation and continuous integration". In daily operation, I believe many people have doubts about how to realize jenkins interface automation and continuous integration. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to realize jenkins interface automation and continuous integration". Next, please follow the editor to study!
1. Install JDK
Go to the official website to download JDK: https://www.oracle.com/java/technologies/javase-jdk15-downloads.html
Put the downloaded compressed package on Linux
Then extract the Java to the appropriate directory:
Enter the command: tar-zxvf jdk-11.0.8_linux-x64_bin.tar.gz / home/java
If prompted for no tar command, enter yum install-y tar and install tar first
Edit the environment variable and add the environment variable to the / etc/profile file:
Enter command: vim / etc/profile
Add the following at the end of the file, and then save:
JAVA_HOME=/home/java/jdk-11.0.8JRE_HOME=$JAVA_HOME/jrePATH=$PATH:$JAVA_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport JRE_HOMEexport PATHexport CLASSPATH
Enter the command source / etc/profile to refresh the environment variable configuration file to take effect immediately
At this point, JDK has been installed. Enter java-version to check whether the installation is successful. The following figure indicates that the installation is successful.
PS: it is recommended to build a hyperlink to Java. This link is created automatically when you install using Java,yum from the / usr/bin/java path by default after establishment.
Enter the command ln-s / home/java/jdk-11.0.8/bin/java / usr/bin/java
two。 Install Jenkins
Official website: https://www.jenkins.io/download/ chooses the corresponding operating system or installs it using yum. Here I use yum because it is more convenient:
There is no Jenkins in yum's repos by default, so we need to add the Jenkins repository to yum repos first.
Click [CentOS/Fedora/Red Hat] system on the official website, and then copy and paste the command into the Linux system.
Then you can see that the system starts to download and install automatically. If prompted, enter: y and press enter. Wait patiently for the installation to complete.
Start Jenkins with the command: service jenkins start. The presence of ok indicates that Jenkins has been started successfully.
Enter ip:8080 in the browser to enter the Jenkins login page and enter the password. At this point, the Jenkins installation is complete.
3. Job configuration
Create a new free-style project
Go to the project configuration page, and under source code management, select Git:
If there is no Git in source code management, you do not have the Git plug-in installed. Click [Manage Jenkins], select [Manage Plugins], select [optional plug-in], enter git plugin in the [search box] to download the plug-in.
Install successfully as shown in the figure, and then restart [Jenkins]:
Build and execute shell and enter pytest commands according to your own script. That is to say, after Jenkins downloads the Git warehouse code, how do we execute the script through commands? fill in this according to your own execution of the script, which is consistent with our manual execution of the script, and then click Save.
Click [Build Now [build now]], and you can see the ongoing build Job.
4. Test report
When the use case execution is complete, we want to see the use case execution, and pytest not only supports the pytest-html plug-in, but also uses allure to generate more beautiful test reports. The Allure framework is a flexible, lightweight multilingual test reporting tool that not only presents the test results in the form of web, but also allows everyone involved in the development process to maximize useful information from the tests performed on a daily basis. So we choose the Allure framework here.
From a dev/qa perspective, the Allure report simplifies the statistics of common defects: failed tests can be divided into bug and interrupted tests, and logs, steps, fixture, attachments, timing, execution history, and integration with TMS and BUG management systems can be configured, so all responsible developers and testers can grasp test information as much as possible through the above configuration.
From a manager's point of view, Allure provides a clear "big picture" of covered features, where defects gather, the appearance of the execution timeline, and many other convenient things. The modularity and extensibility of allure ensures that you can always fine-tune something to make Allure more suitable for you, so today we'll talk about how to make the report show the information we need in more detail, as well as the integration of allure and jenkins.
Download Allure plug-in and configuration Allure
Click [Manage Jenkins], select [Manage Plugins], select [optional plug-in], enter Allure in the [search box] to download the plug-in. Restart Jenkins after a successful download.
Enter the global tool configuration [Global Tool Configuration], drop down the last item, and you will see the "Allure Commandline" item. You can save it after configuring it as shown below:
Enter the configuration, click * * Post-build Actions * *, and select Allure Report
Results: enter the Path path, where the path path means that this folder is generated under the project root, and the folder is used to hold the json,xml,txt and other types of files that you relied on before generating the html report.
Report path: enter the path to save the html report.
Click [Build Now [build now]], and you can see the generated Allure report after the execution is finished.
4.2 Allure report presentation
5. Send an email
Jenkins provides an email notification E-mail Notification by default, but the function has many limitations and is not flexible enough. For example, the format of the message cannot be defined, and the message notification cannot provide detailed message content. Here we use the Email Extension Plugin plug-in. The plug-in allows you to customize the specific content of the email, email format, and so on.
Download Email plug-in and configuration Email
Click [Manage Jenkins], select [Manage Plugins], select [optional plug-in], enter Email Extension Plugin in the [search box] to download the plug-in. Restart Jenkins after a successful download.
Enter the system settings [System Configuration], find [Jenkins Location], and set the email address of Jenkins URL and the sender.
Find "Extended E-mail Notification" and set the following:
Detailed parameters:
Override Global Settings: if not selected, the plug-in will use the default E-mail Notification notification option. Instead, you can override it by specifying a different setting than. Default Content Type: specifies the type of email content to be sent after the build, including Text and HTML. Use List-ID Email Header: set a List-ID header for all messages. Add 'Precedence: bulk' Email Header: sets the priority. Default Recipients: customize the default email recipient list. Reply To List: reply list. Emergency reroute: if this field is not blank, all emails will be sent separately to that address (or address list). Excluded Committers: to prevent messages from being considered spam by the mail system, the mailing list should not have an extended account name (e.g. @ domain.com) and should be separated by commas. Default Subject: the default subject name for custom mail notifications. This option replaces some parameters in the subject field of the message so that the specified output information can be included in the build. Maximum Attachment Size: the maximum attachment size of the message. Default Content: the default content body for custom mail notifications. This option replaces some parameters in the contents of the message so that the specified output information can be included in the build. Default Pre-send Script: the default script executed before sending. Enable Debug Mode: enables the debug mode of the plug-in. Nable Security: when enabled, the ability to send scripts is disabled and goes directly to the Jenkins instance. If a user attempts to access an instance of a Jenkins management object, a security exception is thrown. Content Token Reference: variables that can be used in the mail, all variables are optional.
Enter the configuration, click * * Post-build Actions * *, find * * Extended E-mail Notification * *, and set the following:
Trigger parameter description
Failure: send emails that fail to build immediately. If the "Still Failing" trigger is configured and the status of the last build was "Failure", the "Still Failing" trigger will send an email instead. Unstable: instantly send emails that are not firmly built. If the "Still Unstable" trigger is configured and the status of the last build was "Unstable", the "Still Unstable" trigger will send an email instead. Still Failing: if the status of two or more consecutive builds is "Failure", send this message. Success: send mail if the status of the build is "Successful". If "Fixed" is configured and the status of the last build is "Failure" or "Unstable", the "Fixed" trigger will send an email instead. Fixed: sends a message when the build status changes from "Failure" or "Unstable" to "Successful". Still Unstable: if the status of two or more consecutive builds is "Unstable", send this message. Before Build: send an email when the build begins.
Click [Build Now [build now]], and after the execution is finished. If the execution is successful, the message will not be sent to the recipient; if the execution fails, an email will be sent to the recipient, and the content of the message will be customized according to your situation.
5.2 email presentation
At this point, the study on "how to achieve jenkins interface automation and continuous integration" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.