Jenkins使用记录

参考资料

https://www.cnblogs.com/hanmk/p/6808932.html

https://www.cnblogs.com/gltou/p/15329634.html

1、安装jenkisn、

2、安装jenkisn需要的插件 如 git等、

3、java服务引用 jenkins API三方包

4、Jekins启动,手动在jekins控制面板 创建一个 jenkisn 构建模板,根据具体业务创建

5、将jenkisn创建的 模板内容 复制到 java 服务里,并根据业务进行替换成相应的业务参数

6、Java 服务 加载模板,调用jenkoins API接口,使jenkins创建构建任务

6.1 jenkins 中 新建 item

选择 freestyle project

添加构建的工作空间

在 general 中 选择使用自定义工作空间

6.2

构建源码 。

这里如果不需要拉取代码 如github上 就选择无。

构建触发器 。

也不勾选

6.3

构建环境

选择构建

添加构建步骤

选择 Execute Windows batch command

将 你要执行的脚本 或是命令 写在这里

如我这里的()
<![CDATA[ curl -s http://${agentHost}:{agentPort}/beforeUpgrade?jobName=%JOB_BASE_NAME% chcp 65001 @echo on cd %WORKSPACE%/%JOB_BASE_NAME%/ curl -s -X POST -H "Content-Type: application/json" -d "{paramsStr}" http://${agentHost}:${agentPort}/afterUpgrade ]]>

7、

构建后步骤(如果需要按需要选择,这里我们可以选择allure报告)

添加一下路径

8、

然后点击 保存

10.82.xxx.xxx:3003/job/wyyUpgrade1/config.xml 在浏览器访问这个地址

9、

可以看到 你刚才创建的 那个模板

然后将这个模板 放到 java 服务里。进行调用即可。前提是 你已经安装了 一些你需要的 插件。还有如果有git 包括git的 秘钥凭证之类的。

10、刚才配置后生成的模版

复制代码
<project>
<description>test Upgrade模板</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>D:/Jenkins_new</customWorkspace>
<builders>
<hudson.tasks.BatchFile>
<command>curl -s http://${agentHost}:${agentPort}/before?jobName=%JOB_BASE_NAME% chcp 65001 @echo on cd %WORKSPACE%/%JOB_BASE_NAME%/ ${executeCommand} curl -s http://${agentHost}:${agentPort}/after?jobName=%JOB_BASE_NAME%</command>
<configuredLocalRules/>
</hudson.tasks.BatchFile>
</builders>
<publishers>
<ru.yandex.qatools.allure.jenkins.AllureReportPublisher plugin="allure-jenkins-plugin@2.30.3">
<configPath/>
<jdk/>
<properties/>
<results>
<ru.yandex.qatools.allure.jenkins.config.ResultsConfig>
<path>allure-results</path>
</ru.yandex.qatools.allure.jenkins.config.ResultsConfig>
</results>
<reportBuildPolicy>ALWAYS</reportBuildPolicy>
<includeProperties>false</includeProperties>
<disabled>false</disabled>
<report>allure-report</report>
</ru.yandex.qatools.allure.jenkins.AllureReportPublisher>
</publishers>
<buildWrappers/>
</project>

11、

2024 1122

Jenkisn 控制台 输出 内容,主要看 jenkins脚本的执行情况

D:\Jenkinsw\2058>python run.py src/R3 -v --deviceId

这个就是我们在jenkins构建模板中 调用自动化用力脚本 的 .py命令 这里的模块参数是我们传给他们的, src/R3 或是 src/R1 src/R2 中间用空格隔开

相关推荐
雾岛心情8 分钟前
小铭邮件管理工具箱的界面(公司版)
运维·服务器·工具·o365·小铭邮件工具箱(公司版)
一只鹿鹿鹿11 分钟前
数据库运维与管理规范(WORD)
运维·数据库
King's King32 分钟前
自动化立体仓库系统项目施工要点
运维·自动化
资源分享助手34 分钟前
三网H5小游戏战车向前冲搭建教程(Win+Linux)
linux·运维·服务器
无限进步_1 小时前
Linux权限模型:从rwx到粘滞位
linux·运维·服务器
goyeer2 小时前
【ITIL4】- 服务价值体系
大数据·运维·信息化·自动运维·itil
精益数智小屋2 小时前
设备维护方案核心功能拆解:一套好的设备维护方案如何解决设备突发故障
大数据·运维·网络·数据库·人工智能·面试·自动化
SWAGGY..2 小时前
Linux系统编程:(一)基础指令详解
linux·运维·服务器
Agent产品评测局2 小时前
设备运维自动化预警系统,从0到1落地实操方法:2026企业级架构与智能体选型全指南
运维·人工智能·ai·chatgpt·架构·自动化
一池秋_2 小时前
etc/sudo.conf is owned by uid 10258, should be 0解决
linux·运维·服务器