安装Jenkins

 

# 105

which git
/usr/bin/git

which java
/usr/bin/java

which mvn
/opt/apache-maven-3.8.7/bin/mvn

which jenkins
/usr/bin/jenkins

安装 jdk

安装 git

安装 maven

修改 /opt/apache-maven-3.8.7/conf/settings.xml

安装 nodejs

url:
https://nodejs.org/en/download
https://nodejs.org/en/download/releases
https://nodejs.org/download/release/v16.19.1/

一开始安装的18版本的nodejs,与我自己的centos不匹配,改装的16版本

tar -xf node-v16.19.1-linux-x64.tar.gz 
mv node-v16.19.1-linux-x64 /usr/local/nodejs

vim /etc/profile

#node
export NODE_HOME=/usr/local/nodejs
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules

source /etc/profile
node -v
npm -v

npm install -g yarn
yarn --version

yarn config get registry
yarn config set registry https://registry.npm.taobao.org

安装 Jenkins

https://www.jenkins.io/
wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.346.3-1.1.noarch.rpm --no-check-certificate
yum -y install jenkins-2.346.3-1.1.noarch.rpm

 

修改用户

默认 Jenkins Jenkins

vim /usr/lib/systemd/system/jenkins.service

 

 

 修改端口号

默认8080

vim /usr/lib/systemd/system/jenkins.service

 

上述方案若未生效 可使用下面的方案直接指定脚本执行时的port

vim /usr/bin/jenkins

 

工作目录

jenkins默认工作目录为~/.jenkins,可以通过配置JENKINS_HOME环境变量来指定。
比如在 /etc/profile 中添加 export JENKINS_HOME="/data/jenkins/"

 vim /etc/profile

 export JENKINS_HOME=/run/app/jenkins

source /etc/profile

 

jenkins服务中的配置 
/usr/lib/systemd/system/jenkins.service

 

 
Started by user lcx
Obtained Jenkinsfile from git http://192.168.1.43:8600/caolei/gas_warning_server.git
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/jobs/personal-4s/workspace
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: NONE
using credential 5035fd10-4242-4dd4-b1cd-03b2000c2f6c

 

启动 jenkins

systemctl daemon-reload
systemctl start jenkins
systemctl status jenkins
systemctl stop jenkins

 

# Jenkins服务
/usr/lib/systemd/system/jenkins.service

# Jenkins启动脚本
/usr/bin/jenkins

# Jenkins执行war包
/usr/share/java/jenkins.war

 

前台运行
java -jar /usr/share/java/jenkins.war --httpPort=105

 

查看启动时打印在控制台的初始密码

journalctl -xe
3月 22 16:45:36 lcx.com jenkins[61608]: *************************************************************
3月 22 16:45:36 lcx.com jenkins[61608]: Jenkins initial setup is required. An admin user has been created and a password generated.
3月 22 16:45:36 lcx.com jenkins[61608]: Please use the following password to proceed to installation:
3月 22 16:45:36 lcx.com jenkins[61608]: d67787187e14448ebe03de69e4a60870
3月 22 16:45:36 lcx.com jenkins[61608]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
3月 22 16:45:36 lcx.com jenkins[61608]: *************************************************************
3月 22 16:45:36 lcx.com jenkins[61608]: *************************************************************
3月 22 16:45:36 lcx.com jenkins[61608]: *************************************************************
3月 22 16:45:55 lcx.com jenkins[61608]: 2023-03-22 08:45:55.310+0000 [id=27]        INFO        jenkins.InitReactorRunner$1#onAttained: Completed initialization
3月 22 16:45:55 lcx.com systemd[1]: Started Jenkins Continuous Integration Server.
-- Subject: Unit jenkins.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit jenkins.service has finished starting up.

 

 

设置全局变量

 

 

安装插件

SSH Pipeline Steps   (支持创建Pipeline任务)
Generic Webhook Trigger (支持gitlab提交代码 触发构建)
DingTalk (支持钉钉自动化通知)
 

卸载jenkins

yum remove jenkins

删除Jenkins文件

find / -name jenkins

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

posted @ 2023-03-22 17:14  1156740846  阅读(75)  评论(0编辑  收藏  举报