Jenkins front-end automated deployment

This two-day tossing a bit Jenkins continuous integration, because the company uses its own svn server built to code management, so here is configured for Jenkins to the svn server, Git basically the same configuration, the back also introduced under the management of the project for Github configuration of Jenkins

Before the project after each modification requires a local npm run build time server manually published to facilitate the testing and product view, Jenkins will have automatic packing after just svn or git submitted after continuous integration, it is convenient that the recording for later consultation.

statement:

  1. Packaged items back address addresses are used  , amend its own;my-demo

  2. Another path, etc., according to their own circumstances modification;

1. Install

1.1 install Nginx

Quguan directly under the net direct download, unzip start nginxyou can make, and frequently used commands:

start nginx # start 

nginx - S # reload reload take effect after modifying the configuration 

nginx - S # Reopen reopens the log file 

nginx -t # detect whether the correct configuration file

 

1.2 Installation Jenkins

 

 

 

After the official website to download files from the installation, I am here to install (Mac do not care), the default port 8080, this time the browser access will be able to access the Jenkins home, if you do not pay attention here to install some plug-in installation root directory of C to be wrongC:\Jenkinslocalhost:8080

After a successful here will enter the page, you choose to go somewhere to find an initial password file open password and fill in the box below to verify Recommend installed plug-insInstallsuggested plugins

 

 

After the plugin is installed into the user login screen, set the user name, password and email.

And then prompts Jenkins is ready! → Start using Jenkins ~

 

 

Note that because you want to use node to execute commands after creation, so also need to install plug-ins: , , ,NodeJSPluginDeployto containerGithubPostbuild task

Here the way records about the startup and shutdown services Jenkins command line:

  1. net start jenkins // 启动Jenkins服务

  2. net stop jenkins // 停止Jenkins服务

2. Create a task Jenkins svn project

2.1 New

The left column to create a new task, enter a name for the task, just write one here

 

 

2.2 Configuration

General

It is the main event here, into the newly created task configuration page of the General

 

 

 

Discard the old building is, after detecting a new version to remove the old version of the building

Source Management

 

Is used herein to svn management code,

Construction of the flip-flop

 

 

Here Poll SCM to check if the update frequency indicates constructed, *****expressed per minute, expressed per hourH****

Construct

cd cd C:\Jenkins\workspace\my-demo

node -v

npm -v

cnpm i

npm run build

 

After the build operation

Install the plug after, you can increase the building after the procedure, select the option to increase the script execution after building, concrete can also refer to the article: jenkins deploy shell script execution before the project maven build deployment - https://blog.csdn.net/ minebk / article / details / 73294785Postbuild taskPostbuild task

I have here isLogtextBuildcomplete

Script:

rmdir /q/s C:\nginx-1.14.0\html\my-demo

xcopy /y/e/i C:\Jenkins\workspace\my-demo\my-demo C:\nginx-1.14.0\html\my-demo

 

Copy files to generate good Nginx directory path amend its own

3. Create a task Jenkins Github project

Jenkins continuous integration not only svn project, Git project is also possible, where the project on Github example:

 

 

Other configurations and the same as the above chapter,

So if there is a new push github request, before the automation will be deployed to the server, it can be very convenient.

Try

We configured a try, just github project in a version of casual commit to github:

 

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

 

 

50 seconds later:

 

 

Construction of success! Construction of 54 seconds with a time now access the local server addresses , can already see the compiled version released friends ~http://localhost:8282/vue-element-template

If you want to release a test version, you can modify the script to build their own after operation


Most online posts shades, and even some contradictory, the following articles are summarized in the process of learning, if error, found welcome message pointed out -

reference:

  1. Jenkins compiled using the automatic deployment of web applications

  2. Jenkins + github front-end automated deployment

  3. Jenkins mail notification configuration

  4. jenkins deployment maven project before the building shell script deployment

 

 Source:  SHERlocked93

Guess you like

Origin www.cnblogs.com/cczlovexw/p/11420160.html