常规的打包方式:

提交代码
拉去代码并打包:war包和jar包
上传到服务器
关闭当前程序
启动新的jar包
查看新的jar包是否起作用

jenkins自动化流程:

CI(Continuous integration,中文意思是持续集成)是一种软件开发时间。持续集成强调开发人员提交了新代码之后,立刻进行构建、(单元)测试

CD(Continuous Delivery, 中文意思持续交付)是在持续集成的基础上,将集成后的代码部署到更贴近真实运行环境(类生产环境)中

所以CD是在CI的基础上的操作,简单来讲就是持续部署,

jenkins需要的环境是jdk环境+git环境+maven环境去部署java程序:

mac使用brew安装完成之后:brew services start jenkins 启动:

先进行基本的配置先:

配置

配置全局的环境:

maven:

git

jdk:

安装插件

安装ssh插件:publish over ssh

安装maven项目插件:Maven Integration plugin

新建一个maven项目:

编写ssh server相关:

在全局配置里面配置需要登陆的服务器:

可以点击测试一下是否能够链接到服务器。

Remote Directory 上传到的服务器的那个目录下,非常重要,因为要进入到这个目录去执行jar包

执行的命令里面的脚本:

[root@better.qzqlsj.club jenkinsJar]$cat start.sh
#/bin/bash
/usr/bin/java -jar quan-0.0.1-SNAPSHOT.jar &
if [ $? -eq 0 ]
then
echo "done"
else
echo "back"
fi
[root@better.qzqlsj.club jenkinsJar]$cat stop.sh
#!/bin/bash
echo "Stop Procedure : quan-0.0.1-SNAPSHOT.jar"
pid=`ps -ef |grep java|grep quan-0.0.1-SNAPSHOT.jar|awk '{print $2}'`
echo 'old Procedure pid:'$pid
if [ -n "$pid" ]
then
kill -9 $pid
fi

保存,点击构建即可:

Started by user huolala
Running as SYSTEM
Building in workspace /Users/quan/.jenkins/workspace/quan-login-test
using credential bcd9b4e9-9a63-49ad-a57c-485c07864954
> /usr/local/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/local/bin/git config remote.origin.url https://gitlab.huolala.cn/group-arch/quan-monitor.git/ # timeout=10
Fetching upstream changes from https://gitlab.huolala.cn/group-arch/quan-monitor.git/
> /usr/local/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/local/bin/git fetch --tags --progress -- https://gitlab.huolala.cn/group-arch/quan-monitor.git/ +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/local/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> /usr/local/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision e1f826aceabbd27307ecd4de965dc166574c03e2 (refs/remotes/origin/master)
> /usr/local/bin/git config core.sparsecheckout # timeout=10
> /usr/local/bin/git checkout -f e1f826aceabbd27307ecd4de965dc166574c03e2 # timeout=10
Commit message: "Update pom.xml"
> /usr/local/bin/git rev-list --no-walk e1f826aceabbd27307ecd4de965dc166574c03e2 # timeout=10
Parsing POMs
Established TCP socket on 62030
[quan-login-test] $ /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/bin/java -cp /Users/quan/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/Users/quan/sotfware/apache-maven-3.6.3/boot/plexus-classworlds-2.6.0.jar:/Users/quan/sotfware/apache-maven-3.6.3/conf/logging jenkins.maven3.agent.Maven35Main /Users/quan/sotfware/apache-maven-3.6.3 /Users/quan/.jenkins/war/WEB-INF/lib/remoting-4.5.jar /Users/quan/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /Users/quan/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 62030
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /Users/quan/.jenkins/workspace/quan-login-test/pom.xml -s /Users/quan/sotfware/apache-maven-3.6.3/conf/settings.xml -gs /Users/quan/sotfware/apache-maven-3.6.3/conf/settings.xml install
2020-07-31 16:31:14.190 java[40895:478137] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2020-07-31 16:31:14.190 java[40895:478137] Text input context does not respond to _valueForTIProperty:
2020-07-31 16:31:14.191 java[40895:478137] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2020-07-31 16:31:14.191 java[40895:478137] Text input context does not respond to _valueForTIProperty:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.quan.monitor:quan:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 59, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------------< com.quan.monitor:quan >------------------------
[INFO] Building quan 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
2020-07-31 16:31:15.704 java[40895:478137] imkxpc_getApplicationProperty:reply: called with incorrect property value 4, bailing.
2020-07-31 16:31:15.705 java[40895:478137] Text input context does not respond to _valueForTIProperty:
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quan ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ quan ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/quan/.jenkins/workspace/quan-login-test/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quan ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/quan/.jenkins/workspace/quan-login-test/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ quan ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ quan ---
[INFO] Surefire report directory: /Users/quan/.jenkins/workspace/quan-login-test/target/surefire-reports -------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run. Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ quan ---
[INFO] Building jar: /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.2.RELEASE:repackage (default) @ quan ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-source-plugin:2.1.2:jar-no-fork (attach-sources) @ quan ---
[INFO] Building jar: /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ quan ---
[INFO] Installing /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT.jar to /Users/quan/.m2/repository/com/quan/monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/quan/.jenkins/workspace/quan-login-test/pom.xml to /Users/quan/.m2/repository/com/quan/monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT.pom
[INFO] Installing /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT-sources.jar to /Users/quan/.m2/repository/com/quan/monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT-sources.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.416 s
[INFO] Finished at: 2020-07-31T16:31:20+08:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /Users/quan/.jenkins/workspace/quan-login-test/pom.xml to com.quan.monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT.jar to com.quan.monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT.jar
[JENKINS] Archiving /Users/quan/.jenkins/workspace/quan-login-test/target/quan-0.0.1-SNAPSHOT-sources.jar to com.quan.monitor/quan/0.0.1-SNAPSHOT/quan-0.0.1-SNAPSHOT-sources.jar
channel stopped
SSH: Connecting from host [quandeMacBook-Pro.local]
SSH: Connecting with configuration [txy-1] ...
SSH: EXEC: STDOUT/STDERR from command [cd /jenkinsJar
./stop.sh
nohup sh start.sh] ...
Stop Procedure : quan-0.0.1-SNAPSHOT.jar
old Procedure pid:22316
nohup: ignoring input and appending output to `nohup.out'
SSH: EXEC: completed after 275 ms
SSH: Disconnecting configuration [txy-1] ...
SSH: Transferred 1 file(s)
Finished: SUCCESS

jenkins-learning的更多相关文章

  1. Web API 持续集成:PostMan+Newman+Jenkins(图文讲解)

    本文由葡萄城技术团队于博客园原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 上篇文章我们已经完成了API测试工具选型,接下来是一系列周期性的开发 ...

  2. Jenkins serving Cake: our recipe for Windows

    https://novemberfive.co/blog/windows-jenkins-cake-tutorial/ Where we started, or: why Cake took the ...

  3. jenkins 自定义主题

    一.概述 jenkins更新后,页面css布局都已改变,我现在用的jenkins.css, ( png图片需自定义) #page-body { background-image:url(http:// ...

  4. SpringBoot集成Swagger,Postman,newman,jenkins自动化测试.

    环境:Spring Boot,Swagger,gradle,Postman,newman,jenkins SpringBoot环境搭建. Swagger简介 Swagger 是一款RESTFUL接口的 ...

  5. MindSpore Graph Learning

    技术背景 MindSpore Graph Learning是一个基于MindSpore的高效易用的图学习框架.得益于MindSpore的图算融合能力,MindSpore Graph Learning能 ...

  6. Jenkins 安装的HTML Publisher Plugin 插件无法展示ant生成的JunitReport报告

    最近在做基于jenkins ant  junit 的测试持续集成,单独ant junit生成的junitreport报告打开正常,使用Jenkins的HTML Publisher Plugin 插件无 ...

  7. 【Machine Learning】KNN算法虹膜图片识别

    K-近邻算法虹膜图片识别实战 作者:白宁超 2017年1月3日18:26:33 摘要:随着机器学习和深度学习的热潮,各种图书层出不穷.然而多数是基础理论知识介绍,缺乏实现的深入理解.本系列文章是作者结 ...

  8. Python-Jenkins API使用 —— 在后端代码中操控Jenkins

    最近在工作中需要用到在后台代码中触发Jenkins任务的构建,于是想到Jenkins是否有一些已经封装好的API类库提供,用于处理跟Jenkins相关的操作.下面就简单介绍下我的发现. Linux C ...

  9. 【Machine Learning】Python开发工具:Anaconda+Sublime

    Python开发工具:Anaconda+Sublime 作者:白宁超 2016年12月23日21:24:51 摘要:随着机器学习和深度学习的热潮,各种图书层出不穷.然而多数是基础理论知识介绍,缺乏实现 ...

  10. 【Machine Learning】机器学习及其基础概念简介

    机器学习及其基础概念简介 作者:白宁超 2016年12月23日21:24:51 摘要:随着机器学习和深度学习的热潮,各种图书层出不穷.然而多数是基础理论知识介绍,缺乏实现的深入理解.本系列文章是作者结 ...

随机推荐

  1. 浅谈:redis的主从复制 + 哨兵模式

    浅谈:redis的主从复制 + 哨兵模式 主从模式 ​ 在谈论redis的主从复制之前,我们先回想下mysql的主从搭建过程,第一步呢首先要在主库服务器中修改my.cnf,开启一下bin_log功能, ...

  2. 数据分析刚入门?这几个BI软件你一定得知道!

    在当前乃至未来5年的职场中,将取代你的可能不是 AI ,而是比你"更懂"数据分析的同事.毕竟,现在做什么都讲究"用数字说话",很多岗位在招聘JD中均给出了&qu ...

  3. 在windev中实现BS架构级的灵活排版

    windev是CS架构,但却能够实现BS架构级的灵活排版.玩过CS架构的老铁们,感受应会都如我,如获新生!因为苦于没有一张好画皮久矣!在windev中,要实现灵活,专业,自适应和非常丰富的排版,可以关 ...

  4. 【windows 操作系统】协程

    ◆ 协程 由程序员手动切换. 属于线程,是在线程里面跑的,因此协程又称微线程和线程等.由于不用进行线程上下文切换,因此效率会更高. 资源: 拥有自己的栈空间,大小动态调整. 安全性: 拥有自己的寄存器 ...

  5. 由浅入深--MyBatis系列

    从今天开始将要开始由浅入深--MyBatis系列博客的编写; 主要目录如下: MyBatis基础知识篇 1.由浅入深---ORM简介 2.由浅入深---MyBatis的整体架构 3.由浅入深---第一 ...

  6. 别再问WiFi密码了,HMS Core统一扫码服务让手机一键联网

    现代生活离不开网络.在餐厅.商场等公共场所,手机连接WiFi一直是高频使用场景.虽然公共场所的免费WiFi越来越多,但网络连接过程却很麻烦.有的需要打开网页注册或点击广告链接才能上网,还有的要求下载特 ...

  7. 六、Java方法

    Java方法 何为方法 System.out.println(),那么它是什么呢? ​ System是一个类,out是一个对象,println()是一个方法 Java方法是语句的集合,它们在一起执行的 ...

  8. JAVA基础01----第1章Java开发环境搭建

    一. Java开发环境中涉及的名词:JDK,JRE,JVM A:什么是JVM JVM是java虚拟机(JVM Java Virtual Machine),java程序需要运行在虚拟机上,不同平台有自己 ...

  9. 二级py--day2

    二级py day2-3 1.进程至少活动情况分为:运行状态.就绪状态.等待状态(阻塞状态).创建状态.终止状态 2.进程的特性包括: 并发性和动态性 3.计算机地址位数决定了内存的最大容量,决定了虚拟 ...

  10. thinkphp 框架自带搜索+分页+搜索标红

    ..........控制器方法 public function index() { //接受搜索关键字 $word=input('word'); $where=[]; if (!empty($word ...