jenkins-1-基于 linux 安装
前言
曾经 Windows 上 jenkins 持续集成都是本地或者拉取 git 的代码,但是我们的Windows系统可能不是一直开着机子的。
随着CI/CD的流行,小龙不得不去玩一下 jenkins,然而我们这时应该需要部署到服务器上,会更实用。
环境准备
- linux
- jdk
jdk 可以参考这篇文章:https://www.cnblogs.com/gsxl/p/12128768.html
一、简介
jenkins是开源CI&CD软件领导者, 提供超过1000个插件来支持构建、部署、自动化, 满足任何项目的需要。
没错插件真的很丰富,git、svn等等还可以汉化,自动构建任务。官网:https://jenkins.io/zh/
二、选择版本下载安装
1、选择某个版本直接下载:wget xxx
我这里选择的是最新版本:wget https://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm
[ code]# wget https://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm --2020-01-01 16:05:54-- https://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm Resolving pkg.jenkins.io (pkg.jenkins.io)... 52.202.51.185 Connecting to pkg.jenkins.io (pkg.jenkins.io)|52.202.51.185|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm [following] --2020-01-01 16:05:56-- https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm Resolving prodjenkinsreleases.blob.core.windows.net (prodjenkinsreleases.blob.core.windows.net)... 52.167.88.112 Connecting to prodjenkinsreleases.blob.core.windows.net (prodjenkinsreleases.blob.core.windows.net)|52.167.88.112|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 63235497 (60M) [application/x-redhat-package-manager] Saving to: ‘jenkins-2.204.1-1.1.noarch.rpm’ 33% [============================================================================> ] 21,487,616 92.0KB/s eta 9m 0s
2、rpm -ivh jenkins-2.204.1-1.1.noarch.rpm 进行安装:
由于我已经安装,所以提示已安装了。
[ data]# rpm -ivh jenkins-2.204.1-1.1.noarch.rpm warning: jenkins-2.204.1-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY Preparing... ################################# [100%] package jenkins-2.204.1-1.1.noarch is already installed [ data]#
3、安装成功后,目录所在路径:
/usr/lib/jenkins/:jenkins安装目录,WAR包在这。
/etc/sysconfig/jenkins:jenkins配置文件,需配置端口、权限。
/var/lib/jenkins/:默认的JENKINS_HOME。
/var/log/jenkins/jenkins.log:Jenkins日志文件。
4、默认端口为:8080,需要修改端口,以及权限(方便后续使用,看情况设置)
vi /etc/sysconfig/jenkins
5、保存后,启动 jenkins:/etc/init.d/jenkins start
[ data]# /etc/init.d/jenkins start Starting jenkins (via systemctl): [ OK ] [ data]#
6、[ ok ] 表示成功运行起来了,注意:如果是 [ FAILED],首先检查 JDK 环境是否已经正常。
[ ~]# /etc/init.d/jenkins start Starting jenkins (via systemctl): Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details. [FAILED] [ ~]#
三、浏览器打开:ip+端口号
1、访问:ip+端口号
2、获取密码:cat /var/jenkins_home/secrets/initialAdminPassword
[ ~]# cat /var/jenkins_home/secrets/initialAdminPassword ac8488fed96142fda5c1dd80c40a50be [ ~]#
3、输入后,下一步,安装推荐的插件即可(安装失败可以尝试几次,实在不行先进去再更改插件下载地址再下载)
4、设置账号密码等信息,下一步设置URL,保存完成就开始享用jenkins:
请问这里可以用shell来安装吗?答案是肯定的,欢迎来QQ交流群:482713805