Jenkins安装部署
Jenkins安装
安装docker,自行百度
docker pull jenkins/jenkins:lts
docker images
#jenkins/jenkins lts 22b8b9a84dbe 2 weeks ago 568MB
docker inspect 22b8b9a84dbe
#查看相关信息
mkdir /home/jenkins_home
docker run -d --name jenkins_01 -p 8081:8080 -v /home/jenkins_01:/home/jenkins_01 jenkins/jenkins:lts
docker ps
#563c4eb8048b jenkins/jenkins:lts "/sbin/tini -- /usr/…" 18 minutes ago Up 18 minutes 50000/tcp, 0.0.0.0:8081->8080/tcp jenkins_01
docker logs 563c4eb8048b
可以查看Jenkins的初始密码
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
558272cfbc834416bb475a31e3c7ffe3
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
远程登录 http://ip:8081
输入初始密码,安装默认的包
Docker 容器的启动和停止
jenkins报错停止工作后使用,比如
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fc12f000, 40386560, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 40386560 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/hs_err_pid6.log
服务器太烂,内存爆了
docker start 563c4eb8048b
docker stop 563c4eb8048b
自行更换containerID,重启容器即可
如果网页可以访问的话,直接访问ip:port/restart
即可
Jenkins+Github测试
打开Jenkins首页
Manage Jenkins -> Global Tool Configuration -> Git
默认为git即可
我是用的是Django项目做的测试
错误1: ‘xxx’ command not found
原因:
没有加载环境变量
解决方案:
加入#!/bin/bash -ilex
错误2:等待施工
参考:
docker安装jenkins最新版本
jenkins构建GitHub项目
jenkins 执行sh脚本 没携带环境变量,报错command not founds问题