In the morning, I did some work on Jenkins continuous integration. Since the company uses the SVN server built by itself for code management, Jenkins is configured for THE SVN server here, and the Jenkins configuration for the project managed by Github is briefly introduced later

Before, after each modification of the project, the local NPM run build was required to be manually released to the server for testing and product viewing. With Jenkins continuous integration, it will be packaged automatically as long as SVN or Git submits, which is very convenient. This record is for later inquiry.

Statement:

  1. The following project address and package address are usedem-mes, self-modification;
  2. In addition, there are paths and so on, according to their own circumstances to modify;

If you are interested, you can join the wechat group at the end of the article and discuss with us

1. Install

1.1 installationNginx

Nginx start nginx start nginx

start nginx  # start
nginx -s reload  Modify the configuration and reload it to take effect
nginx -s reopen  # Reopen the log file
nginx -t  Check whether the configuration file is correct
Copy the code

There are many tutorials online, so I won’t repeat them

1.2 installationJenkins

After downloading the file from the official website and installing it, I installed it to C:\Jenkins with the default port 8080. At this time, the browser can access the Jenkins home page by visiting localhost:8080

This will tell you to go somewhere and find an initial password file, open it, and fill in the password box below. Once verified, go to the page and select Install Suggested plugins

After the plug-in is installed, enter the user login interface and set the user name, password and email.

Then prompt Jenkins is ready! → Start using Jenkins ~

Note that you need to install the NodeJS Plugin, Deploy to Container, Github, and Post Build Task to perform the post-create operation using node commands

Note the command line to start and stop the Jenkins service:

Net Start Jenkins net Stop Jenkins Net Start Jenkins net Stop JenkinsCopy the code

2. Create Jenkins task for SVN project

2.1 new

Create a new task in the left column, enter a task name, write a random one here

2.2 configuration

General

Here is the highlight, go to General on the configuration page for the task you just created

Discarding an old build is the removal of an old build when a new one is detected

Source code management

SVN is used here to manage the code,

Build trigger

Here the Poll SCM represents the frequency at which builds are checked for updates, ***** per minute and H**** per hour

build

cd cd C:\Jenkins\workspace\em-mes
node -v
npm -v
cnpm i
npm run build
Copy the code

Post-build operation

After installing the plugin Post Build Task, you can select the Post Build Task option to add the script executed after the build. For details, see article Jenkins Deployment Maven Project Execute shell scripts after Build and before deployment

My Log text here is Build complete

Script:

Rmdir /q/s C:\nginx-1.14.0\ HTML \em-mes xcopy /y/e/ I C:\Jenkins\workspace\em-mes\em-mes C:\nginx-1.14.0\ HTML \em-mesCopy the code

Copy the generated file to the Nginx directory and change the path

Create the Jenkins task for the Github project

Jenkins can not only continuously integrate SVN project, but also Git project. Here, take the project on Github as an example

Other configurations are the same as in the previous chapter

This way, if github has a new push request, it will be automatically deployed to the previous server

Give it a try

Commit any version of the github project to Github

Wait a moment to address local Jenkins http://localhost:8080/job/vue-element-template/ can see Jenkins has been in the building

After 50 seconds

Build successful! Build in 54 seconds, accessing a local address http://localhost:8282/vue-element-template, now can already see the compiled release ~ if you want to test version is released, can modify the build script after operation


Online posts are mostly different in depth, even some inconsistent, the following article is a summary of the learning process, if you find mistakes, welcome to comment out ~

Reference:

  1. Automatically compile and deploy web applications using Jenkins
  2. Jenkins+ Github front-end automation deployment
  3. Configure Jenkins email notification
  4. Jenkins executes shell scripts after deploying maven project build and before deploying

PS: Welcome to pay attention to my official account [front-end afternoon tea], come on together

In addition, you can join the “front-end afternoon tea Exchange Group” wechat group, long press to identify the following TWO-DIMENSIONAL code to add my friend, remarks add group, I pull you into the group ~