CentOs下面安装jenkins记录

目录


一、安装jenkins

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

2 rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

3 yum upgrade

4 yum install jenkins java-11-openjdk.x86_64

5 systemctl start jenkins.service

如启动失败

如上错误是java配置错误,官方安装的本本2.387以上需要jdk11

如有安装其他版本,请卸载,只留下Java11

再关闭防火墙(systemctl stop firewalld)

再次启动:systemctl start jenkins

systemctl status jenkins

说明启动成功

切换源

二、进入jenkins

1 ip:8080

2 cat /var/lib/jenkins/secrets/initialAdminPassword

3 输入密码

4 选择默认插件即可

5 设置管理员

三、安装和Gitee,Maven , Publish Over SSH等插件

更换插件镜像地址,

问题1 启动日志报错:

安装git插件

yum -y install git

问题2:无mvn命令

从官方或者其他途径下载maven

设置maven访问阿里镜像,找到maven的settings.xml文件

vim settings.xml

修改:

<mirror> <id>nexus-aliyun</id> <mirrorOf>*</mirrorOf> <name>Nexus aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> </mirror>

添加:<localRepository>/repository/</localRepository>

配置Maven的环境变量

vi /etc/profile

翻到最后一行加上下面的内容, 保存退出(注意MAVEN_HOME是实际Maven的路径)

export MAVEN_HOME=/usr/maven/apache-maven-3.5.4

PATH=$PATH:$MAVEN_HOME/bin

重新加载:source /etc/profile

给运行权限: chmod a+x /usr/maven/apache-maven-3.5.4/bin/mvn

问题3:文件夹不存在

mkdir /repository

chmod 777 /repository

恭喜练成神功第一层

设置maven的setting文件

四、构建一个maven项目

1、设置SSH远程推送文件

2、构建一个Maven任务,并配置项目源

添加执行脚本: clean install -Dmaven.test.skip=true

3、增加构建后操作(Send build artifacts over SSH):前提需要安装此插件Publish Over SSH

经验分享 程序员 微信小程序 职场和发展