The front end of the project to achieve the deployment package by Jenkins

First, the environment
  1. jenkins environment
  2. Git plug, pulling the code for the code library
  3. Publish Over SSH plug for connecting remote SSH server
  4. NodeJS environment
  5. Test used front-end demo, address: https://gitee.com/hsh2015/vue-test.git
Second, the system configuration

1. Global configuration NodeJS
in Manage Jenkins [] - [Configuration of the Global Tool Configuration NodeJS]. When you configure NodeJS, NodeJS choose their own locally installed, fill in the name, and configure NodeJS installation path. Interface is as follows:

Here Insert Picture Description
2. Publish over SSH arranged in the Configure System in
the Configure System] [-] [Publish over SSH, configure the username and password via a remote server, arranged as follows:
Here Insert Picture Description
Verify SSH configuration is successful, as shown below:
Here Insert Picture Description

Third, create automatic deployment pipeline

Create an automated deployment process, and on a similar way, only the construction of the project and project release some way to resolve differences.

  1. Creating a project
    Click [Home] - [New Item] to enter the project to create a page, fill in the name, select "Freestyle project", then click "OK" and to go to the next step.
    Here Insert Picture Description
  2. Project General configuration
    Here Insert Picture Description
  3. Source Code Management
    this step you need to install Git plugin, otherwise Git option does not appear, the steps to install the plug will not be repeated here. Here choose Git, and then configure the Git repository path, and then add Credentials, if not created, you can "Add" to add.Here Insert Picture Description
  4. Build Environment Configuration
    Select "Provide Node & npm bin / folder to PATH" can, using the default configuration to the other.
    Here Insert Picture Description
  5. Build Configuration
    Configuration constructed project through nodejs, and packaged for remote transmission.
    Here Insert Picture Description
cd /root/.jenkins/workspace/testAdmin #进入test项目目录
cnpm install --unsafe-perm
npm run build
cd dist
rm -rf testAdmin.tar.gz #删除上次打包生成的压缩文件
tar -zcvf testAdmin.tar.gz * #把生成的项目打包成test方便传输到远程服务器
  1. Post-build Actions
    from the previous step packaged file, SSH transmission to the designated location of the server, and then extract the tar command to the appropriate location.
    Caveats : the SSH remote transmission, storage position of the file is: Path Remote directory configuration is configured Publish over SSH + Remote directory path Send build artifacts over SSH configured in the Configure System. Then the compressed file to extract the nginx tomcat corresponding file or directory.
    Here Insert Picture Description
  2. After configuring the pipeline, the build process started
    selecting the configuration in the item [My Views], and [click] Build Now start the building process, as shown below:
    Here Insert Picture Description
    Then by [] into the Console Output log output process of building interfaces,
    Here Insert Picture Description
    Here Insert Picture Description
Published 48 original articles · won praise 3 · Views 3114

Guess you like

Origin blog.csdn.net/hou_ge/article/details/103507947