If you encounter any problems during the process, you can communicate with each other.

Also very hope each big guy can give good suggestion.


Jenkins

concept

  • Jenkins is an open source CI&CD software for automating a variety of tasks, including building, testing, and deploying software.

  • Jenkins supports a variety of operations, either through system packages, Docker, or through a standalone Java program.

Why learn

  • The company in
  • Slightly better job responsibilities likejenkinsAnd so on (continuous integration, automated deployment), are basically more or less mentioned.
  • The traditional way is to start one on the servergitWarehouse, and then after each code update, manual pull, too many times is tired, and these only need to be configured once before the project startsjenkinsA lot of manual operation costs are reduced

Front task

  • centOsThe server
  • git,linux,shellJust the basics.
  • nginxBasic configuration.

The opening preparation

The initial onevuecliProject, visit below

ingithubCreate a warehouse

configurationgithub webhook

http://ip:8080/github-webhook/

directory

  • Jenkins environment building
  • New Jenkins task
  • Nginx access

Environment set up

Logging In to the Server

The installationjavaRely on

yum install java
Copy the code

usewgetaddJenkins source

wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
Copy the code

Use after installationyumThe command will be downloaded.

yum install jenkins
Copy the code

Jenkins changes access port or something, right there

vim /etc/sysconfig/jenkins
Copy the code
  • JENKINS_PORT – > JenkinsStart the port, the default8080
  • JENKINS_USER -> Jenkins userroot
// Here I have changed JENKINS_USER to root. JENKINS_USER="root"Copy the code

usechowntojenkinsDesignation of ownership

chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins
Copy the code

Start thejenkins

service jenkins restart
Copy the code

Ok, ok

accessjenkins

IP address + 8080Copy the code

Here’s what it looks like on my first visit.

The image circled in red is replaced with the one displayed on your page

cat /val/jenkins_home/xxxx/xxx
Copy the code

Then copy the display to the input box and click Next.

Then go to the Install plug-in page

Here is the install recommended plug-in option.

Just wait, a little long loading…

Create a user

And then you go over here and Jenkins is set up and you hit start.

A new task

Building triggers is listeninggithubwebhookIf there is any newpushThen rebuild. I’m gonna save it

Click 🌞(sun) in the W column for a description of the build, and if the build fails, you can follow the tips here to locate the problem.

I was kind of blindsided here, and I was thinking where is the built file, and how do I access it?

The storage address after the build

cd /var/lib/jenkins/workspace
Copy the code

Now we are going to modify the configuration informationshell

node -v
npm -v
npm install
npm run build
Copy the code

Found a build failure?

But that’s okay

Let’s go to plug-in management for global Settings

After downloading it, we went to Global Configuration Management and found the correct NodeJs option.

Ah, after all, to finally see our favoritedistHere your shell commands can be automatically expanded, such as moved to another location.

nginx

cd /etc/nginx/conf.d vim test-jenkins.conf server { listen 8000; Server_name _; Location / {# here I point to the directory where Jenkins built, or I can move the file somewhere else in the shell at build time. root /var/lib/jenkins/workspace/test-jenkins/dist; try_files $uri $uri/ index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}Copy the code

Then open IP :8000 to access.

last

Let’s re-push locally and see if this page changes.

If 404 Not Found is Not Found, NPM run build will delete dist first.

To complete our basic configuration,