If you want to learn from scratch Docker, Take a look at this series of articles !
https://www.cnblogs.com/poloyy/category/1870863.html
build Jenkins Containers
It's the first article in actual combat :https://www.cnblogs.com/poloyy/p/13954637.html
Jenkins Initialization flow
visit Jenkins
View this machine IP
ifconfig6·rtyjie
Check the container run port
docker ps
I use the mainframe 80 The port maps to the container 8080 port
Browser access Jenkins
http://ip:80
Check the administrator password
Go to the page
There are two ways to view passwords
The first one is : View container log
docker logs jenkins1
The code line is the password
The second kind : Go to the folder and check
cat /var/jenkins_node/secrets/initialAdminPassword
- Because I created Jenkins When the container , Will host the /var/jenkins_node The directory maps the container's /var/jenkins_home Catalog
- So you can directly find the administrator password in the host , You don't have to go into the container to see
Initialization flow
Create administrator user
Just remember what you deserve , No special requirements
The instance configuration
By default, an address will be given , It's ok if you don't change it
Configuration complete
Enter the main interface
Download plug-ins
Plug in needed gitlab、gitlab hook、allure
After it's installed , Restart by yourself Jenkins Containers
docker restart jenkins1
Switch plug-in source to domestic source
Look directly at this tutorial :https://www.cnblogs.com/poloyy/p/12785401.html
Jenkins Sinicization
Look directly at this tutorial :https://www.cnblogs.com/poloyy/p/13955209.html
Jenkins Global tool Settings
To configure JDK
To configure Git
To configure allure
Application save ! that will do !
Jenkins Email function test
To configure Extended E-mail Notification
Custom e-mail = Default recipient list for notifications
- Can be used in projects $DEFAULT_RECIPIENTS , To include this default recipient list ( Let's talk about this variable when creating a project )
- To ask sb CC or BCC , Instead of putting it in “ The recipient ” In the list , Please add... Before your email address cc: Or BCC bcc: ( for example :cc:[email protected],bcc:[email protected])
Configure mailbox notification
Use Jenkins Implement automated testing
Put the project in the directory where the host is mapped to the container
adopt xftp Upload the project to the host
This is one of my own pytest project
Verify that the project can run normally
Enter the container , Execute in the project folder pytest command
Yes 28 All the test cases have passed
Jenkins Create a task project
A new task
Jenkins Operation after the task configuration is built
After setting up the system , It also needs to be done for projects that need to be built Email configuration
a key : There is $DEFAULT_RECIPIENTS , This environment variable is also mentioned above , Default recipient list , If you need to add a new recipient message , Need to use , separate
Email template
Just copy and paste it into the content box
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>${ENV, var="JOB_NAME"}- The first ${BUILD_NUMBER} Secondary build log </title> </head> <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0"> <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif"> <tr> This message is sent automatically by the system , Don't need to reply !<br/> Dear colleagues , Hello everyone , The following is a ${PROJECT_NAME } Project build information </br> <td><font color="#CC0000"> The build results - ${BUILD_STATUS}</font></td> </tr> <tr> <td><br /> <b><font color="#0B610B"> Build information </font></b> <hr size="2" width="100%" align="center" /></td> </tr> <tr> <td> <ul> <li> Project name : ${PROJECT_NAME}</li> <li> Build number : The first ${BUILD_NUMBER} Time to build </li> <li> trigger : ${CAUSE}</li> <li> Build status : ${BUILD_STATUS}</li> <li> The build log : <a href="${BUILD_URL}console">${BUILD_URL}console</a></li> <li> structure Url : <a href="${BUILD_URL}">${BUILD_URL}</a></li> <li> working directory : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li> <li> project Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></li> <li> Test report : <a href="${PROJECT_URL}allure">${PROJECT_URL}allure</a></li> </ul> <h4><font color="#0B610B"> Failure case </font></h4> <hr size="2" width="100%" /> $FAILED_TESTS<br/> <h4><font color="#0B610B"> Recently submitted (#$SVN_REVISION)</font></h4> <hr size="2" width="100%" /> <ul> ${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="%c", changesFormat="<li>%d [%a] %m</li>"} </ul> Submit in detail : <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a><br/> </td> </tr> </table> </body>
The last save
Build for the first time
View console output
Mail sent successfully !!
Jenkins Task configuration build operation
There are two main tasks
- To configure pytest command
- Generate allure The report
To configure pytest command
#!/bin/bash cd /var/jenkins_home/waimai pytest -s -q --alluredir=${WORKSPACE}/allure-reports --clean-alluredir exit 0
Generate allure The report
This picture is the key point
preservation !! It was successful !
Do a second build
see allure The report