Linux Debian Jenkins快速搭建配置并运行

2023-11-20

Jenkins安装

参考Debian Jenkins Packageshttps://pkg.origin.jenkins.io/debian-stable/

加Key

 curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
    /usr/share/keyrings/jenkins-keyring.asc > /dev/null

加仓库

  echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
    https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list > /dev/null

更新索引,并安装依赖库,再安装jenkins 

fontconfig openjdk-11-jre
  sudo apt-get update
  sudo apt-get install fontconfig openjdk-11-jre
  sudo apt-get install jenkins

Jenkins服务运行

开启服务

sudo systemctl start jenkins

检查是否正在运行

sudo systemctl status jenkins

在浏览器种输入下面的URL,打开Jenkins,默认端口8080

http://your_server_ip_or_domain:8080

解锁Jenkins

第一次在浏览器中访问Jenkins时,您将被提示解锁Jenkins。初始admin密码可以在以下文件中找到:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

复制密码到浏览器解锁Jenkins.

配置Jenkins:

按照说明设置Jenkins,可以根据需要安装插件和配置Jenkins。

运行Jenkins服务:

要确保Jenkins在启动时自动启动,并作为系统服务进行管理,请执行以下命令:

sudo systemctl enable jenkins

Jenkins启动排错

若启动失败,可以检查log,Java依赖库报错

启动时查看syslog,得知java版本不匹配

 # tail -f /var/log/syslog

 systemd[1]: Started Session 13 of user ute.
 systemd[1]: Started Session 14 of user ute.
 systemd[1]: Starting Jenkins Continuous Integration Server...
 jenkins[5941]: jenkins: invalid Java version: java version "1.8.0_341"
 jenkins[5941]: Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
 jenkins[5941]: Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
 systemd[1]: jenkins.service: Main process exited, code=exited,status=1/FAILURE
 systemd[1]: jenkins.service: Failed with result 'exit-code'.
 systemd[1]: Failed to start Jenkins Continuous Integration Server.
 systemd[1]: jenkins.service: Service RestartSec=100ms expired,scheduling restart.
 systemd[1]: jenkins.service: Scheduled restart job, restart counter is at 1.
 systemd[1]: Stopped Jenkins Continuous Integration Server.
 systemd[1]: Starting Jenkins Continuous Integration Server...

上面虽然已经安装最新的openjdk-11-jre,但是查看java版本仍然是老的版本

# java -version

java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)

执行update-alternatives --config java

# update-alternatives --config java
update-alternatives: warning: alternative /usr/lib/jvm/jre-8-oracle-x64/bin/java (part of link group java) doesn't exist; removing from list o                                            f alternatives
update-alternatives: warning: /etc/alternatives/java is dangling; it will be updated with best choice
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/jre-8-oracle-x64/bin/java
Nothing to configure.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jre-8-oracle-x64/bin/java because link group java is broken
update-alternatives: warning: current alternative /usr/lib/jvm/jre-8-oracle-x64/bin/java is unknown, switching to /usr/lib/jvm/java-11-openjdk                                            -amd64/bin/java for link group java

# update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.

# java -version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Debian-1deb10u1)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Debian-1deb10u1, mixed mode, sharing)

或尝试检查默认Jenkins端口8080是否被占用:

# netstat -nltp | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN                                                                         1416/apache2

修改Jenkins默认端口

# vi /etc/default/jenkins

# defaults for Jenkins automation server

# pulled in from the init script; makes things easier.
NAME=jenkins

# arguments to pass to java

# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="-Djava.awt.headless=true"

#JAVA_ARGS="-Xmx256m"

# make jenkins listen on IPv4 address
#JAVA_ARGS="-Djava.net.preferIPv4Stack=true"

PIDFILE=/var/run/$NAME/$NAME.pid

# user and group to be invoked as (default to jenkins)
JENKINS_USER=$NAME
JENKINS_GROUP=$NAME

# location of the jenkins war file
JENKINS_WAR=/usr/share/java/$NAME.war

# jenkins home location
JENKINS_HOME=/var/lib/$NAME

# set this to false if you don't want Jenkins to run by itself
# in this set up, you are expected to provide a servlet container
# to host jenkins.
RUN_STANDALONE=true

# log location.  this may be a syslog facility.priority
JENKINS_LOG=/var/log/$NAME/$NAME.log
#JENKINS_LOG=daemon.info

# Whether to enable web access logging or not.
# Set to "yes" to enable logging to /var/log/$NAME/access_log
JENKINS_ENABLE_ACCESS_LOG="no"

# OS LIMITS SETUP
#   comment this out to observe /etc/security/limits.conf
#   this is on by default because http://github.com/jenkinsci/jenkins/commit/2fb288474e980d0e7ff9c4a3b768874835a3e92e
#   reported that Ubuntu's PAM configuration doesn't include pam_limits.so, and as a result the # of file
#   descriptors are forced to 1024 regardless of /etc/security/limits.conf
MAXOPENFILES=8192

# set the umask to control permission bits of files that Jenkins creates.
#   027 makes files read-only for group and inaccessible for others, which some security sensitive users
#   might consider benefitial, especially if Jenkins runs in a box that's used for multiple purposes.
#   Beware that 027 permission would interfere with sudo scripts that run on the master (JENKINS-25065.)
#
#   Note also that the particularly sensitive part of $JENKINS_HOME (such as credentials) are always
#   written without 'others' access. So the umask values only affect job configuration, build records,
#   that sort of things.
#
#   If commented out, the value from the OS is inherited,  which is normally 022 (as of Ubuntu 12.04,
#   by default umask comes from pam_umask(8) and /etc/login.defs

# UMASK=027

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080


# servlet context, important if you want to use apache proxying
PREFIX=/$NAME

# arguments to pass to jenkins.
# full list available from java -jar jenkins.war --help
# --javaHome=$JAVA_HOME
# --httpListenAddress=$HTTP_HOST (default 0.0.0.0)
# --httpPort=$HTTP_PORT (default 8080; disable with -1)
# --httpsPort=$HTTP_PORT
# --argumentsRealm.passwd.$ADMIN_USER=[password]
# --argumentsRealm.roles.$ADMIN_USER=admin
# --webroot=~/.jenkins/war
# --prefix=$PREFIX

JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT"

防火墙设置

解决:Jenkins本地浏览器可访问,但是其他主机无法访问

缺少Jenkins port

# /usr/sbin/iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http-alt
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:snmp:snmp-trap
ACCEPT     udp  --  anywhere             anywhere             udp dpts:snmp:snmp-trap
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:319:320
ACCEPT     udp  --  anywhere             anywhere             udp dpts:ptp-event:ptp-general
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:5900:5901
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:webmin
ACCEPT     udp  --  anywhere             anywhere             udp dpt:10000
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:10010
ACCEPT     udp  --  anywhere             anywhere             udp dpt:10010
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:10020
ACCEPT     udp  --  anywhere             anywhere             udp dpt:10020
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:20000
ACCEPT     udp  --  anywhere             anywhere             udp dpt:20000
ACCEPT     tcp  --  anywhere             anywhere             tcp dpts:8880:8881
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

允许jenkins port(8888) 进出,并临时保存防火墙配置(重启失效)


# /usr/sbin/iptables -i eth0 -I INPUT -p tcp -m tcp --dport 8888 -j ACCEPT

# /usr/sbin/iptables-save

永久保存防火墙配置,重启还在

# /usr/sbin/netfilter-persistent save
run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables save
run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables save
# /usr/sbin/netfilter-persistent reload
run-parts: executing /usr/share/netfilter-persistent/plugins.d/15-ip4tables start
run-parts: executing /usr/share/netfilter-persistent/plugins.d/25-ip6tables start

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux Debian Jenkins快速搭建配置并运行 的相关文章

  • Bazel远程缓存分析数据

    我正在 jenkins 上的 docker 容器内运行 bazel 通过 bazelisk 此外 我使用远程缓存 在不进行任何更改的后续运行中 我获得 100 的缓存命中 但每次创建新容器时都会运行分析阶段 约 60 秒 有没有办法远程缓存
  • 使用 shell 脚本在 Jenkins 中手动构建失败吗

    我想将 Jenkins 构建标记为在一种情况下失败 例如 if f file then echo file found else echo file not found Do Jenkins Build Fail fi 可以通过Shell脚
  • Eclipse CDT 内置包含目录

    Under Eclipse CDT gt Project Settings gt C C General gt Paths and Symbols gt Includes gt GNU C 有一个包含路径的列表 有些是粗体的并且是特定于项目
  • 调试严重的 SIGILL 崩溃:文本段损坏

    我们的系统是基于 PowerPC 的运行 Linux 的嵌入式系统 我们遇到了随机的 SIGILL 崩溃 这种情况在各种应用程序中都会出现 崩溃的根本原因是将要执行的指令归零 这表明内存中的文本段已损坏 由于文本段是以只读方式加载的 因此应
  • Jenkins 在解析 pom 时失败

    我的 Jenkins 服务器上的一项作业出现问题 在 pom 解析期间失败并显示以下消息 Parsing POMs Modules changed recalculating dependency graph workspace java
  • 在 Ubuntu 12.04 中打开 eclipse juno 并出现错误“No more handles ...”

    从今天开始 每次我打开 Eclipse 时 都会弹出一个标题为 出现问题 的消息框 内容如下 不再处理 未知的 Mozilla 路径 未设置 MOZILLA FIVE HOME 可能的参数 0 1 2 3 不再有句柄 未知的 Mozilla
  • find 命令的“exec”功能可以在后台启动程序吗?

    我想做这样的事情 find iname Advanced Linux Program exec kpdf 可能的 还有其他类似的方法吗 首先 它不会像你输入的那样工作 因为 shell 会将其解释为 find iname Advanced
  • 从该共享库中查找加载的共享库的位置?

    从共享库中的函数 在正在运行的进程 用 C 编写 内 我如何发现该共享库是从哪里加载的 我找到的所有答案都涉及使用诸如ldd在命令行中 或者通过查看 proc self maps 在 Win32 上 我只需使用GetModuleFileNa
  • 如何在 Linux 上使用 Python 导出

    我需要在 Python 中进行这样的导出 export MY DATA my export 我尝试过这样做 python mode coding utf 8 import os os system export MY DATA my exp
  • 如何从 ext2/ext3 文件系统上的稀疏文件中删除一些块

    当您写入稀疏文件时 ext2 ext3 文件系统会自动分配块 但是当我不再需要其中的某些块时 我发现没有办法做到这一点 感觉就像使用 malloc 而不使用 free 是否可以 释放 稀疏文件的某些块 如果是的话 怎么样 不要告诉我将其复制
  • 如何使用AWK从文件中连续输出行

    我有一个多行文件 我想连续输出文件的某些行 比如第一次 从第1行打印到第5行 下次 打印第2行到第6行 依此类推 我发现 AWK 是一个非常有用的函数 我尝试自己编写代码 但它什么也没输出 以下是我的代码 bin bash for n in
  • VS Code 不会构建具有多个 .cpp 源文件的 C++ 程序

    请注意 我在 Ubuntu 17 10 上使用 VS Code 并使用 GCC 编译器 我在构建一个使用附加 cpp 文件的简单程序时遇到问题 我可能在这里遗漏了一些明显的东西 因为我对编程相当陌生 但我会解释到目前为止我所做的事情 这阻止
  • 如何从 Jenkins 文件调用 groovy 脚本?

    我正在尝试将 Jenkinsfile 中的内容分离成一个常规脚本来制作 但它无法调用这些脚本 这是代码 usr bin env groovy node test node stage Checkout echo BRANCH NAME en
  • 输出bash脚本的结果

    例如 如果我选择运行一个 bash 脚本 该脚本将输出 回显 时间 例如CheckDate sh 我如何从 Java 运行它 然后在我的 Java 程序中打印 bash 脚本的结果 日期 试试这个代码 String result null
  • 使用 Jenkins 作业将 Helm 图表部署到 Kubernetes

    我想创建一个 Jenkins 作业 将 Helm Chart 部署到 Kubernetes 集群中 Helm 图表存储在 Bitbucket 存储库中 pipeline agent any stages stage Download Hel
  • Android Studio无法更新

    我正在运行 Mint 14 Linux 并且在使用 Android Studio 时遇到了一个主要问题 运行更新功能时 所有软件包都会返回 访问被拒绝 状态 我怎样才能解决这个问题 如何授予下载和安装的权限 附加信息 studio sh 正
  • FLTK 1.4 小部件位置 w.r.t. X11 根窗口?

    context 我正在和其他人一起编码参考系统 http refpersys org C 17 上的 GPLv3 项目gitlab https gitlab com bstarynk refpersys适用于 GNU Linux x86 6
  • Windows 从属设备上的 Jenkins Git SSH 密钥

    目前 我们在 Windows 上有一个 Jenkins 主服务器 一个 ubuntu 从服务器和一个 Windows 从服务器 我正在尝试在 Windows 从机上设置 git msysgit 已安装 并且我将该目录包含在系统路径变量中 以
  • 无法从外部 bash 脚本正确设置 MySQL 密码

    我有两个脚本 主要的一个脚本执行一些不同的操作并调用第二个脚本 第二个脚本安装 MySQL 从我的主脚本中我做了这样的事情 read p Set the password for the database min 4 characters
  • 将文件夹中结构化的预构建文件集添加到 android out 文件夹

    我为arm编译了glibc 这与Android glibc或bionic C不同 因为我编译的glibc环境将有助于提供更多api 现在我可以在 Android 运行时将 glibc 环境复制到 system 文件夹中 并且在执行 chro

随机推荐

  • Webpack 5 超详细解读(四)

    31 proxy 代理设置 为什么开发阶段需要设置代理 在开发阶段 我们需要请求后端接口 但是一般后端接口地址和我们本地的不在同一个服务中提供 这时进行访问就会存在跨域的问题 所以我们需要对我们的请求进行转啊操作 模拟跨域请求代码如下 ht
  • Java容器有哪些?哪些是同步容器,哪些是并发容器?

    Java容器有哪些 哪些是同步容器 哪些是并发容器 一 基本概念 容器集 同步容器 并发容器 二 Collection集合接口 List接口 LinkedList类 ArrayList类 Vector类 Stack类 Set接口 HashS
  • SQL报错——Incorrect column specifier for column ‘id‘

    自增 字段类型应该设置为int类型
  • C++面试 左值、右值、左值引用、右值引用

    1 左值和右值 左值 left values 缩写 lvalues located value 可定位值 其含义是可以明确其存放地址的值 更确切说对其的使用是基于地址 右值 right values 缩写 rvalues read valu
  • 【shell脚本通过curl调用判断k8s pod 是否启用成功】

    获取到指定的pod name viewer kubectl n skiff nsfdemo ns get pod grep viewer awk print 1 根据pod name 获取指定pod IP viewerIp kubectl
  • 【源码篇】基于SSM+JSP实现的学生宿舍管理系统

    系统介绍 基于SSM JSP实现的学生宿舍管理系统是一个基于B S模式的学生宿舍管理系统 为学生 学校和宿管阿姨搭建了一个灵活自由并且安全可靠的管理平台 系统设计了6大菜单模块 分别是 学生管理 学生信息的添加 修改 删除 查询 Excel
  • VScode+PHPstudy配置PHP开发环境详解

    这篇文章主要介绍了VScode PHPstudy配置PHP开发环境的步骤 整理了官方以及优秀第三方的内容 对于学习和工作有一定借鉴意义 准备安装的软件 VScode和PHPstudy 链接 https pan baidu com s 1T2
  • HTTP报文结构

    1 URL HTTP使用统一资源定位符 URL 协议 主机 端口 路径 2 HTTP 3 HTTP请求报文 请求行 首部 空行 主体 客户端发送一个HTTP请求到服务器的请求报文如下 1 请求行 方法 URL 空行 协议的版本 中间空格隔开
  • Qt公有槽和私有槽的区别

    Qt遵循C 的规则 当槽函数作为一个成员函数 公有槽可以被其他类调用 而私有槽只能被类自身调用 当槽函数被信号触发而被调用时 公有槽和私有槽没有区别 它们都能被外部信号触发 参考链接 https stackoverflow com ques
  • JavaEE学习记录day11 IO流02 字符流、转换流、Properties集合

    1 字符流 1 1为什么会出现字符流 理解 字符流的介绍 由于字节流操作中文不是特别的方便 所以Java就提供字符流 字符流 字节流 编码表 中文的字节存储方式 用字节流复制文本文件时 文本文件也会有中文 但是没有问题 原因是最终底层操作会
  • 黑幕!阿里P8爆出学透这份算法面试文档,不再怕任何大厂算法题

    为什么要学习数据结构和算法 随着应用程序变得越来越复杂和数据越来越丰富 几百万 几十亿甚至几百亿的数据就会出现 而对这么大对数据进行搜索 插入或者排序等的操作就越来越慢 数据结构就是用来解决这些问题的 阅读本教程前 您需要了解的知识 在您开
  • FastDFS storage服务器安装Nginx

    环境准备 操作系统 Centos 服务器 192 168 60 165 storage服务器 软件包 fastdfs nginx module 1 20 tar gz nginx 1 14 0 tar gz 软件包下载地址 待补充 第一步
  • Hive 窗口函数如何设置窗口大小

    select city year taxes sum money over as sample1 所有行相加 sum money over partition by city as sample2 按city分组 组内数据相加 sum mo
  • Linux下用inotify-tool实时监控服务器文件

    说明 服务器系统 CentOS 文件目录 home web os 实现目的 当 home web os下面除过cache目录之外 任何文件发生变化时 记录日志并保存 具体操作 一 安装Inotify tools工具 1 查看服务器内核是否支
  • Android SurfaceFlinger服务(三) ----- 本地图层Layer创建

    在上一篇文章中 主要分析了Surface的创建过程 对于Layer图层的创建并没有深入跟踪分析 这篇文章将分析Layer图层的创建 并分析handle gbp这两个变量的来源 在SurfaceFlinger中会根据flags的值创建不同的l
  • CMake中include的使用

    CMake中的include命令用于从文件或模块 file or module 加载并运行CMake code 其格式如下 include
  • 【算法】Dijkstra最短路算法

    上周我们介绍了神奇的只有五行的Floyd最短路算法 它可以方便的求得任意两点的最短路径 这称为 多源最短路 本周来来介绍指定一个点 源点 到其余各个顶点的最短路径 也叫做 单源最短路径 例如求下图中的1号顶点到2 3 4 5 6号顶点的最短
  • VS+QT开发Ocx/ActiveX控件 一

    VS QT开发Ocx ActiveX控件 一 VS QT开发Ocx ActiveX控件 网页中全屏 二 QT开发ActiveX控件 一 所用IDE版本 需用管理员权限 二 创建ActiveX 三 qt desinger 四 regsvr32
  • java虚拟机win10_Win10系统启动软件出现Java虚拟机错误的解决方法

    在 1 为Java设置新的系统变量 当Java需要更大的全局最大堆内存大小时 通常会出现Java虚拟机错误 用户通过扩展分配给Java的最大RAM来解决该问题 用户可以通过建立新的Java System Variable来实现 如下所示 使
  • Linux Debian Jenkins快速搭建配置并运行

    Jenkins安装 参考Debian Jenkins Packageshttps pkg origin jenkins io debian stable 加Key curl fsSL https pkg jenkins io debian