Linux install jenkins
docker install jenkins
1 | docker pull jenkins/jenkins:lts |
user jar install jenkins
- 安装jdk8
创建用户
1
2
3
4useradd -g user -d /home/jenkins -m jenkins
passwd jenkins
su - jenkins
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/war-stable/2.150.1/jenkins.war启动脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43/bin/bash
: << !
for start jenkin by java -jar
!
# set jenkins_home path
if [[ ! -n `grep "JENKINS_HOME" ~/.bash_profile` ]];then
sed -i '$aexport JENKINS_HOME='${HOME}'/jenkins_home' ~/.bash_profile
echo 'add jenkins home'
else
echo 'jenkons home already in bash_profile'
fi
# mkdir jenkins_home
if [[ ! -d ${HOME}/jenkins_home ]] ; then
mkdir -p ${HOME}/jenkins_home
echo 'mkdir jenkins home'
else
echo -e 'jenkins home is already in '${HOME}''
fi
# jenkins run or not and kill
jenkins_pid=`ps -ef | grep 'java -jar jenkins.war'| grep -v grep| awk '{print $2}'`
if [ ${jenkins_pid} > 1 ];then
echo 'jenkins is running'
echo "kill jenkins ? please input (y\n)"
read char
if [ ${char} = 'y' ];then
kill -9 ${jenkins_pid}
echo 'kill jenkins success'
else
echo 'not kill jenkins and exit'
exit 0
fi
else
echo 'no jenkins is running'
fi
# start jenkins
nohup java -jar jenkins.war --ajp13Port=-1 --httpPort=8081 >/dev/null 2>&1 &
echo "start jenkins with command: 'nohup java -jar jenkins.war --ajp13Port=-1 --httpPort=8081 >/dev/null 2>&1 &'"
echo `ps -ef | grep 'java -jar jenkins.war'| grep -v grep| awk '{print $2}'`初始密码
1
2more .jenkins/secret/initialAdminPassword
more ~/jenkins_home/secret/initialAdminPassword