常规的打包方式:

提交代码
拉去代码并打包: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. IPv6 OSPFv3路由协议测试——信而泰网络测试仪实操

    关键词 IPv6; OSPFv3; OSPFv2. 前言:在网络部署中,动态路由协议是重要的组成部分.良好的路由协议,是保证网络可靠.稳定运行的基础.为了适应IPv6协议栈的变化,OSPFv3协议在保 ...

  2. 企业必读:BI数据可视化工具选型

    伴随着大数据时代的到来,企业对数据的需求从"IT主导的报表模式"转向"业务主导的自助分析模式",可视化BI工具也随之应运而生.面对如此众多的可视化BI工具,我们 ...

  3. md5非对称密钥

    一.MD5加密概述 Message Digest Algorithm MD5(中文名为消息摘要算法第五版)为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护.该算法的文件号为RFC 13 ...

  4. 什么是句柄C#

    话不多说,下面分享下我对句柄的看法. 如果没有意外的话,ABCDE他们将依次进行占用CPU资源.但是可能会发生如下情况 句柄,就是用来维护进程或者系统范围内的一个标识.就比如我们去访问一个文件的时候, ...

  5. 2020ICPC上海站 C. Sum of Log

    题目大意: 给定T组X,Y,对于每组X,Y,求上面式子   的值,其中  当x为真时等于1,其他情况等于0. 其中. 思路: 对X,Y一起进行数位DP,我们把每一位枚举数字的上限以及数字之前是否有前导 ...

  6. UnboundLocalError: local variable ‘xxx‘ referenced before assignment

    原因 在Python函数中调用了某个和全局变量同名的局部变量,导致编译器不知道此时使用的是全局变量还是局部变量 a = 3 def func(): a+=3 func() UnboundLocalEr ...

  7. Pandas:各种错误

    1.输出为CSV文件时,Permission denied 原因可能是: (1).构建DataFrame时没有写index参数 (2).用Dict构建最开始的数据时,value没有写成List的形式, ...

  8. python面试_总结03_列表练习题

    1.列表练习题 完成下列列表相关的编程题,先运行下列的test函数,在完成每道题之后,都可以通过调用test函数检测所写函数对错. def test(got, expected): if got == ...

  9. JZ-011-二进制中 1 的个数

    二进制中 1 的个数 题目描述 输入一个整数,输出该数32位二进制表示中1的个数.其中负数用补码表示. 题目链接: 二进制中 1 的个数 代码 /** * 标题:二进制中 1 的个数 * 题目描述 * ...

  10. 虚拟机服务启动失败报错npm ERR! code ELIFECYCLE

    可能是由于node_modules模块中缺失或者某些东西冲突引起的,我们可以使用如下的方法解决这个: rm -rf node_modules 删除,不询问 rm package-lock.json 删 ...