赞
踩
目录
本篇文章简介: 简单易上手, 轻松实现jenkins实现自动化部署(上)
--->1.1.1 直接安装 修改安装路径 设置端口号 9000为例
---> 2.1.1 修改 jenkins.xml文件(示例如下, 就是你jenkins的安装路径
---> 2.2.1 (安装插件) maven 搜 Maven Integration
---> 2.2.2 安装 Publish Over SSH
--->2.3.1 操作方式: 首页-> 系统管理 -> 全局配置 找到maven安装
---> 2.5.2 配置git (基本操作 账号 密码 仓库地址)
---> 2.5.4 点击触发器 点击构建 调用顶层maven目标
-> 3.1创建并执行jar包 尝试关闭./shutdown.sh
-> 3.2 创建并执行jar包 尝试启动 ./startup.sh
编辑 -> 4.2 安装插件ssh 搜索Publish Over SSH
-> 4.4 拉到下面 找到ssh servers 填写服务器基本信息
->5.7 点击运行 build now, 查看控制台输出日志 正确如图
实现了jenkins基础安装配置, gitee拉取 , 推送服务器 杀死进程 启动进程的自动化操作
特邀 hyn 提供技术支持
--->1.1.1 直接安装 修改安装路径 设置端口号 9000为例
---> 1.1.2 创建工作空间即可 (起名为pzy)
我这里是 D:\software\jenkins\pzy\Jenkins 不然默认是c盘
- <!--
- The MIT License
- Copyright (c) 2004-2017, Sun Microsystems, Inc., Kohsuke Kawaguchi, Oleg Nenashev, and other Jenkins contributors
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- -->
- <!--
- Windows service definition for Jenkins.
- To uninstall, run "jenkins.exe stop" to stop the service, then "jenkins.exe uninstall" to uninstall the service.
- Both commands don't produce any output if the execution is successful.
- -->
- <service>
- <id>jenkins</id>
- <name>Jenkins</name>
- <description>This service runs Jenkins automation server.</description>
- <env name="JENKINS_HOME" value="D:\software\jenkins\pzy\Jenkins\.jenkins"/>
- <!--
- if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
- The following value assumes that you have java in your PATH.
- -->
- <executable>C:\Program Files\Java\jdk1.8.0_201\\bin\java.exe</executable>
- <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "D:\software\jenkins\jenkins.war" --httpPort=9000 --webroot="D:\software\jenkins\pzy\Jenkins\war"</arguments>
- <!--
- interactive flag causes the empty black Java window to be displayed.
- I'm still debugging this.
- <interactive />
- -->
- <logmode>rotate</logmode>
-
- <onfailure action="restart"/>
-
- <!--
- In the case WinSW gets terminated and leaks the process, we want to abort
- these runaway JAR processes on startup to prevent corruption of JENKINS_HOME.
- So this extension is enabled by default.
- -->
- <extensions>
- <!-- This is a sample configuration for the RunawayProcessKiller extension. -->
- <extension enabled="true" className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension" id="killOnStartup">
- <pidfile>D:\software\jenkins\pzy\Jenkins\jenkins.pid</pidfile>
- <stopTimeout>10000</stopTimeout>
- <stopParentFirst>false</stopParentFirst>
- </extension>
- </extensions>
-
- <!-- See the referenced examples for more options -->
-
- </service>
任务管理器-> 服务-> 搜索jenkins -> 右键重新启动
根据红字内的地址 找到你本地的文件夹 复制粘贴即可
解决: cmd命令(java -verbose)
添加账号密码凭证
指令如下: clean install -Dmaven.test.skip=true 打包
自动maven进行构建 (第一次可能会很慢), 可以看日志, 然后看jar包保存位置
设定 jar包存放在 /opt/app下
-> 3.1创建并执行jar包 尝试关闭./shutdown.sh
- #!/bin/bash
-
- #删除历史数据
- #rm -rf xxoo
-
- appname=$1
- #获取传入的参数
- echo "arg:$1"
-
-
- #获取正在运行的jar包pid
- pid=`ps -ef | grep $1 | grep 'java -jar' | awk '{printf $2}'`
-
- echo $pid
-
- #如果pid为空,提示一下,否则,执行kill命令
- if [ -z $pid ];
- #使用-z 做空值判断
- then
- echo "$appname not started"
-
- else
- kill -9 $pid
- echo "$appname stoping...."
-
- fi
-> 3.2 创建并执行jar包 尝试启动 ./startup.sh
- APP_NAME=$1
- echo $APP_NAME
- /opt/app/shutdown.sh $APP_NAME
- source /etc/profile
- nohup /usr/local/jdk1.8.0_45/bin/java -jar -Xms512m -Xmx512m -XX:PermSize=128M -XX:MaxPermSize=256M $APP_NAME --spring.profiles.active=test >>/opt/app/nohup.out 2>&1 &
- echo "success"
- sleep 10s
- chmod +x startup.sh
- chmod +x shutdown.sh
正常安装
<实现单项目自动化部署>
我的位置如下: D:\software\jenkins\pzy\Jenkins\.jenkins\workspace\pzy-test
jps -v -l 查看 启动参数和jar包名
到此 jenkins上篇结束 多个服务 操作相似
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。