Jenkins has been deployed on the corresponding server. The front-end deployment needs to create tasks and do some configuration.
First of all:
Login Jenkins graphical interface, plug-in installation skipped, system management - plug-in management, NodeJs plugin and Git. After the plug-in is installed, go to the system configuration on the home page, find global tool configuration, find nodejs in it, and add installation. Here I choose Node 14.Copy the code
The second step:
After you have the basic conditions, jump to the home page, create a task in the corresponding view, that is, our project deployment task, and select free style software Project. [If there are configuration items that can be copied, enter the name of the task to be copied.]Copy the code
Step 3:
In project configuration, fill in the description, source configuration, and build environment (in this case, select the previously installed version of Node). Build module, select execute shell, code as follows:Copy the code
#!/bin/bash
echo $PATH // Update environment variables
node -v // Output the node version
npm -v // Output the NPM version
npm config set registry https:/ / registry.npm.taobao.org / / modify source of NPM
npm install // Execute the install dependency
npm install -D node-sass@4.141. // If the download fails each time, simply execute it separately
npm run build // Perform packaging
cd dist // Enter the package file
rm -rf test.tar.gz // Delete the last compressed file
tar -zcvf test.tar.gz * // Compress all the contents of the package file
echo "Complete compression"
Copy the code
Source file write dist/test.tar.gz, prefixed with dist and the file name corresponding to the front-end directory on the server. After the build, you need to upload the compressed file to the server and decompress the overwrite file, with the Exec command below.Copy the code
#!/bin/bash source /etc/profile cd ... Here write the front-end code on the server file directory address such as /usr/main/htm/project tar -zxvf test.tar.gz rm -rf test.tar.gzCopy the code
The fourth step
In this case, I'm using Xshell to log in to the server and find the nginx.conf file. Run vim nginx.conf to fill in the required port file directory and agent information. Run nginx -s reload to refresh Nginx.Copy the code
The last
At this point, the configuration is complete, click the task to start deployment, you can view the detailed progress in the console.Copy the code