CentOS 7 jenkins 代码构建同步

第一步 安装java 版本 默认8

1 yum list java-1.8* 查看镜像源 有没有java 源包

2 yum install java-1.8.0-openjdk* -y 直接安装jdk

3 java -version 查看java的版本

第二步 安装jenkins 进行初始配置

1 wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
   下载jenkins 的源

2 rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key 
  RPM 安装到镜像区

3 yum install jenkins 开始安装jenkins 

4 vim /etc/sysconfig/jenkins 
  配置端口和用户权限 root
  JENKINS_USER="root"  JENKINS_PORT="8086"

5 service jenkins start 启动它  

第三步 nginx反代jenkins 防止暴露端口

1 添加jenkins.conf 文件 增加以下配置
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;
        }
}

第四步 开始部署jenkins 构建环境 不全部演示 就一些细节记录

1 cat /var/lib/jenkins/secrets/initialAdminPassword 查看默认的密码进行配置

2 安装 配置 NodeJS 插件 必须版本一致 不然各种依赖问题

3 要配置ssh 密钥 不然没有拉代码权限 Credentials 凭证
主要要增加私钥
npm install -g yarn 安装yarn 打包工具

4 默认的工作目录在 /var/lib/jenkins/workspace
<https://www.594cto.com/content/dea480fab9344954aef42e6d01996f68>

5 shell 脚本
/usr/local/bin/yarn -v
/usr/local/bin/yarn install
/usr/local/bin/yarn build:dev
/usr/local/nginx/sbin/nginx -s reload
1、查看服务器当前时间命令:date
2、修改服务器系统时间命令:date -s "月/日/年 时:分:秒",如:date -s "12/16/19 20:02:01"
3、将服务器时间改为跟网路同步(恢复时间)命令:ntpdate cn.pool.ntp.org
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 1

docker pull jenkins 不香吗

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!