Jenkins free style project updates website static files

If you want to update the website, you must first create a new task, and write the name of the website in the task name.

Now, updating the static logo image does not require compilation, so creating a maven project will not be used here. Here, we choose to build a free-style software project (no need to use make ant maven to compile).

After creating the task, you need to do some configuration

 Now this is a function that can pull down the code from the svn warehouse. The svn warehouse address is svn:139.224.227.121:8801/edu/vv1. The local module directory is the directory where the code is to be downloaded. The dot represents the project directory. Repository depth represents the project directory. Sometimes the project directory has multiple levels. Here, the entire project directory is downloaded. Quiet check-out represents a silent migration. The migration method is use 'svn update' as much as possible. If the code is updated, only the updated code will be migrated out, not all of it.

 A username and password are required to access the warehouse, click Add

The code repository has been specified. It is best to scroll to the bottom and click Apply to save.

The most important thing about the above operations is to write a warehouse address. Now the only function of this task is to pull down the code files of the svn warehouse and pull them to the Jenkins server.

Build your mission

In the console output, you can see that the pulled code files are pulled to the /root/.jenkins/workspace/discuz.test.net directory under the Jenkins server. --quite means silent printing and does not display the name of the moved-out file.

 You can see that the code files (logo.png, index.html) have been moved to the jenkins server. 

[root@localhost ~]# cd /root/.jenkins/workspace/discuz.test.net/
[root@localhost discuz.test.net]# ll
total 20204
-rw-r--r--. 1 root root     2381 Oct 27 19:17 index.html
-rw-r--r--. 1 root root     3685 Oct 27 19:17 logo.png

Jenkins has pulled the static images locally. How can we ask Jenkins to help us update the website's logo? 

Select the build environment in the task configuration, then select Execute shell, and write the shell command to be deployed.

Here we are updating a website on a server. Keyless import needs to be configured before updating.

ssh -l root 192.168.179.104 "mkdir -p /data/backup/`date +%F`"
ssh -l root 192.168.179.104 "\cp /var/www/html/static/image/common/logo.png /data/backup/`date +%F`"
ssh -l root 192.168.179.104 "ls -l /data/backup/`date +%F`"
scp /root/.jenkins/workspace/discuz.test.net/logo.png [email protected]:/var/www/html/static/image/common

Build the task and watch the console output 

 You can see that the output station information is normal, and then check to see if the website logo has been updated.

You can see that the update through the jenkins website is successful. 

Guess you like

Origin blog.csdn.net/qq_34556414/article/details/109305937#comments_28735950