java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

Jenkins 配置一个springboot 项目自动发布

Jenkins是什么

Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件项目可以进行持续集成
个人理解为一连串的脚本组合成为发布的工具

jenkins官方网址
https://www.jenkins.io/download/lts/macos/

Jenkins安装启动

MAC 下安装jenkins

brew install jenkins-lts

卸载
brew uninstall jenkins-lts
Uninstalling /opt/homebrew/Cellar/jenkins-lts/2.303.3... (8 files, 72.3MB)

启动方式1:brew services start jenkins-lts
重启动 brew services restart jenkins-lts

启动方式2:
/opt/homebrew/opt/openjdk@11/bin/java -Dmail.smtp.starttls.enable=true -jar /opt/homebrew/opt/jenkins-lts/libexec/jenkins.war --httpListenAddress=127.0.0.1 --httpPort=8080

访问URL http://localhost:8080/

默认控制台出来一串密码

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

5396cb930bab4858b18fe1e489abfd85

This may also be found at: /Users/ge/.jenkins/secrets/initialAdminPassword

输入即可,然后选择插件安装

plug

Jenkins忘记密码

密码忘记了

cd /Users/xxx/.jenkins/users/admin_15012535494078703792

vi config.xml

找到如下内容,进行替换

<hudson.security.HudsonPrivateSecurityRealm_-Details>
<passwordHash>#jbcrypt:$2a$10$oZgKQuNVqiMglf2lqPm2WOfXqZoq5gWt4NvrT1iugjCNEtVDsUP1G</passwordHash> 
</hudson.security.HudsonPrivateSecurityRealm_-Details>
<passwordHash>#jbcrypt:$2a$10$oZgKQuNVqiMglf2lqPm2WOfXqZoq5gWt4NvrT1iugjCNEtVDsUP1G</passwordHash> 
表示密码为admin

修改完成重启动服务

账户admin
密码admin

Jenkins集成Maven发布SpringBoot项目

image-20220816142749121

点击侧面的Manage Jenkins, 然后选择Manage Plugins, 点击到可选插件里,搜索maven,Maven Integration这个插件打钩安装

image-20220816142928584

需要maven构建插件
Maven Integration plugin

本地JAVA_HOME配置

chmod 773 /etc/profile
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile

新建一个Maven项目

image-20220816143324029

设置git的地址,账户密码

image-20220816144301224

Goals and options

clean package -Dmaven.test.skip=true

image-20220816143607550

点击the tool configuration 去配置maven的选项

image-20220816144121190

/Users/ge/.jenkins/workspace/jenkins001_mvn/target/jenkins001-0.0.1-SNAPSHOT.jar

cd /Users/ge/.jenkins/workspace/jenkins001_mvn/target/
name=`ls |grep jenkins001-|grep -v original`
#删除变量 name从右边开始的第一个.和.后面的所有字符
jarname=${name%.*}
echo ${name}
echo ${jarname}
nohup java -jar ${name} > /Users/ge/Desktop/cc.log &

安装启动
https://www.jianshu.com/p/5f671aca2b5a

jenkins gitlab 配置2022.07.12
http://t.zoukankan.com/gongxr-p-9257434.html

maven构建
https://www.jianshu.com/p/a84cded92117

读取pom.xml生成的jar的版本
http://t.zoukankan.com/keeptesting-p-10970737.html


This entry was posted in JAVA, Linux and tagged , , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/jenkins-maven-springboot/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply