First, the environment
- jenkins environment
- Git plug, pulling the code for the code library
- Publish Over SSH plug for connecting remote SSH server
- NodeJS environment
- 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:
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:
Verify SSH configuration is successful, as shown below:
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.
- 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.
- Project General configuration
- 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. - Build Environment Configuration
Select "Provide Node & npm bin / folder to PATH" can, using the default configuration to the other.
- Build Configuration
Configuration constructed project through nodejs, and packaged for remote transmission.
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方便传输到远程服务器
- 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.
- 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:
Then by [] into the Console Output log output process of building interfaces,