background

Company of the front-end and back-end build and deploy job is artificial, with business expanding, the project iteration speed faster, all sorts of problems are exposed, the increase in the number of people will pass through a simple case to share based on the before and after the end of the Jenkins workflow of process automation, finish building the workflow, we only need to launch a locally git commit, The remaining single package construction, code deployment, email reminders and other functions are all automated, making continuous integration, continuous delivery and continuous deployment simple and easy to operate, and truly solving many problems of manual construction and deployment.

What is Jenkins?

Jenkins is a popular open source continuous integration tool, widely used in project development, with automated build, test and deployment capabilities.

War file to install

  1. Download the Jenkins War pack from the official website
  2. Command start,java -jar jenkins.war --httpPort=8080

You can use-server -Xms1024m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=512m3. Open the browserhttp://127.0.0.1:8080/4. Find the initialization password5. Select the default plug-in6. Wait until the download is complete7. Set a login password

Download the plugin

Manage Jenkins->Manage Plugins-> Advanced (bottom)

Increase download speed instead of default Url

http://mirror.esuni.jp/jenkins/updates/update-center.json

Manage Jenkins->Manage Plugins-> Optional plug-ins

Install the following plug-ins

  1. Publish Over SSH Is used to connect to the remote server
  2. The Deploy to Container plug-in is used to publish packaged applications to remote servers
  3. Maven Integration plugin
  4. Pipeline Maven Integration Plugin
  5. Gitlab Hook Plugin (automatically compiled when git commits)
  6. GitLab Plugin (automatically compiled when Git is submitted)
  7. GitLab Authentication Plugin (GitLab Authentication Plugin)
  8. WebHook (automatically compiled when git commits)
  9. Locale-> set zh-cn
  10. Dingding Plugin Jenkins notification
  11. Multiple SCMs (configure Multiple Git)
  12. Git Parameter plug-in

Global configuration

Manage Jenkins->Global Tool Configuration

Publish over SSH (multiple servers can be configured for remote push)

Creating a New Maven Project

Click on theThe new Item

Note: If there is a parent-child relationship between the program, the parent project first install to the warehouse. Or download the plugin: Multiple SCMsReference Address:Jenkins Configuration Tutorial Task –>configure–>Build–>Goals and options: The clean package – Dmaven. Repo. Local = D: / dev/maven3.1.1 \ m2repository

If you want to commit code after the automated buildConfiguration required :(permissions required) After the configuration is successful Click Test to test automatic deployment

Jenkins Parametric configuration (select branch deployment)

Git Parameter

2. Configure parameter properties

3. Final effect

Jenkins configures pin notifications

1, the configuration of nail robot2, install the nail notification plug-in

3. Configure notification after project construction

4. Configure Jenkins to send messages to Dingding

5. Final results

Jenkins Authority Management

Install plug-in role-based Authorization Strategy Access: Jenkins Permission Management Reference

Jenkins server performs shell scripts across services without encryption

Scenario: In many cases Jenkins is deployed as a standalone server, sending the packaged service pack to the target server for startup. Inevitably there are customizations in the operation:

For example, back up the service package running on the current server before sending the target server. You need a customized shell script to perform this operation. Every time you type in a password, it’s not gonna work.

So Jenkins server is required to log in to the target server without secret configuration.

Reference: [xiaobai] Linux password free login

The appendix

Docker deployment is not recommended. Use WAR to start Jenkins

Download mirror

docker pull jenkins/jenkins:lts
Copy the code

The installation image

docker run --name jenkins --user=root -p 8080:8080 -p 50000:50000 -v /Users/wei/Documents/jenkins_home:/var/jenkins_home -d jenkins/jenkins:lts
Copy the code

Unload the container

docker rm -f $(docker ps -a |  grep "jenkins"  | awk '{print $1}')
Copy the code

reference

Jenkins 英 文 版

Jenkins deploys the Nodejs tutorial

Jenkins Multijob Plugin for continuous integration