首先去官网下载个Jenkins.war
https://www.jenkins.io/zh/download/
然后上传到指定目录
我放在了这里
先创建jenkins目录
[root@localhost updates]# mkdir jenkins
启动war包,需要按两次回车
[root@localhost jenkins]# ls jenkins.war [root@localhost jenkins]# nohup java -jar /usr/local/jenkins/jenkins.war >/usr/local/jenkins/jenkins.out & [2] 97577 [root@localhost jenkins]# nohup: 忽略输入重定向错误到标准输出端 [root@localhost jenkins]#
访问Jenkins
http://自己的IP地址:8080
如图:
找到管理员密码位置
/root/.jenkins/secrets/initialAdminPassword
[root@localhost jenkins]# cat /root/.jenkins/secrets/initialAdminPassword
217708c7c9a94e01851120276e26481e
多等一会儿【先不要安装插件,往下看】
查看Jenkins进程
[root@localhost jenkins]# ps -ef | grep jenkins. root 97375 91749 2 11:05 pts/2 00:00:38 java -jar /usr/local/jenkins/jenkins.war root 97774 91749 0 11:27 pts/2 00:00:00 grep --color=auto jenkins.
注意:要关掉浏览器,并配置国内的镜像
官方下载插件慢 更新下载地址
cd {你的Jenkins工作目录}/updates #进入更新配置位置
sed -i 's/http://updates.jenkins-ci.org/download/https://mirrors.tuna.tsinghua.edu.cn/jenkins/g' default.json && sed -i 's/http://www.google.com/https://www.baidu.com/g' default.json
这是直接修改的配置文件,如果前边Jenkins用sudo启动的话,那么这里的两个sed前均需要加上sudo
重启Jenkins,安装插件
先杀死Jenkins
[root@localhost jenkins]# ps -ef | grep jenkins. root 97375 91749 2 11:05 pts/2 00:00:38 java -jar /usr/local/jenkins/jenkins.war root 97774 91749 0 11:27 pts/2 00:00:00 grep --color=auto jenkins. [root@localhost jenkins]# kill -9 97375 [root@localhost jenkins]# ps -ef | grep jenkins. root 97785 91749 0 11:28 pts/2 00:00:00 grep --color=auto jenkins. [1]+ 已杀死 nohup java -jar /usr/local/jenkins/jenkins.war > /usr/local/jenkins/jenkins.out(工作目录:/usr/local) (当前工作目录:/usr/local/jenkins) [root@localhost jenkins]# ps -ef | grep jenkins. root 97787 91749 0 11:28 pts/2 00:00:00 grep --color=auto jenkins.
然后进入到Jenkins配置文件目录
[root@localhost jenkins]# cd /root/.jenkins/ [root@localhost .jenkins]# ls config.xml hudson.model.UpdateCenter.xml jenkins.install.UpgradeWizard.state jobs nodeMonitors.xml plugins secret.key.not-so-secret updates users failed-boot-attempts.txt identity.key.enc jenkins.telemetry.Correlator.xml logs nodes secret.key secrets userContent war [root@localhost .jenkins]# cd updates/ [root@localhost updates]# ls default.json hudson.tasks.Maven.MavenInstaller
在执行这个语句,什么都不提示就是好消息,安装配置改成功了
[root@localhost updates]# sed -i 's/http://updates.jenkins-ci.org/download/https://mirrors.tuna.tsinghua.edu.cn/jenkins/g' default.json && sed -i 's/http://www.google.com/https://www.baidu.com/g' default.json [root@localhost updates]#
查看default.json
[root@localhost updates]# tail default.json
。。。。。。。。。。很多
[root@localhost updates]# ps -ef | grep jenkins.
root 98067 91749 0 11:50 pts/2 00:00:00 grep --color=auto jenkins.
[root@localhost updates]#
静默方式重启
[root@localhost updates]# nohup java -jar /usr/local/jenkins/jenkins.war >/usr/local/jenkins/jenkins.out & [1] 98120 [root@localhost updates]# nohup: 忽略输入重定向错误到标准输出端 [root@localhost updates]# ps -ef | grep jenkins. root 98120 91749 74 11:54 pts/2 00:00:07 java -jar /usr/local/jenkins/jenkins.war root 98168 91749 0 11:54 pts/2 00:00:00 grep --color=auto jenkins. [root@localhost updates]#
再次登录Jenkins安装插件
创建用户,为了好记,用户名和密码我使用本地MySQL的名和码
使用默认