CentOS 7 Jenkins code build synchronization

Time:2020-11-30

The first step is to install the Java version, which is 8 by default

1 Yum list java-1.8 * check whether the image source has java source package

2 Yum install java-1.8.0-openjdk * - y install JDK directly

3 Java - version view java version

The second step is to install Jenkins for initial configuration

1 wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
   Download Jenkins source

2 rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key 
  RPM installed in mirror area

3 Yum install Jenkins 

4 vim /etc/sysconfig/jenkins 
  Configure port and user rights root
  JENKINS_USER="root"  JENKINS_PORT="8086"

5 service Jenkins start

In the third step, nginx reverses Jenkins to prevent exposing ports

1 add jenkins.conf  Add the following configuration to the file
server{
        listen       80;
        server_name  xxxx;
        #access_log /var/log/jenkins_access_log main;
        error_log  /var/log/jenkins_error_log  debug_http;
        client_max_body_size 60M;
        client_body_buffer_size 512k;
        location / {
                proxy_pass
                http://localhost:8086;
                proxy_redirect  off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

The fourth step starts to deploy Jenkins, and the construction environment is not fully demonstrated, but some details are recorded

1 cat / var / lib / Jenkins / secrets / initialadminpassword view the default password for configuration

2. Installing and configuring nodejs plug-ins must have the same version, otherwise various dependency problems will occur

3. To configure the SSH key, otherwise you do not have permission to pull code credentials
The main thing is to increase the private key
NPM install - G yarn install yarn packaging tool

The default working directory is / var / lib / Jenkins / workspace
<https://www.594cto.com/content/dea480fab9344954aef42e6d01996f68>

5 shell script
/usr/local/bin/yarn -v
/usr/local/bin/yarn install
/usr/local/bin/yarn build:dev
/usr/local/nginx/sbin/nginx -s reload
1. View server current time command: Date
2. Modify the server system time command: date - s "month / day / year hour: minute: second", such as: date - s "12 / 16 / 19 20:02:01"
3. Change the server time to synchronize with the network (recovery time) command: ntpdate cn.pool.ntp .org

This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint