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="[email protected]">
<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 中间用空格隔开

相关推荐
云计算-Security14 分钟前
Jenkins 执行器(Executor)如何调整限制?
运维·jenkins
***似水流年***24 分钟前
Linux任务管理与守护进程
linux·运维·服务器
天天爱吃肉82181 小时前
车载以太网驱动智能化:域控架构设计与开发实践
java·运维·网络协议·微服务
愚润求学2 小时前
【Linux】进程间通信(一):认识管道
linux·运维·服务器·开发语言·c++·笔记
SHUIPING_YANG3 小时前
Nginx 返回 504 状态码表示 网关超时(Gateway Timeout)原因排查
运维·nginx·gateway
光不度AoKaNa3 小时前
计算机操作系统概要
linux·运维·服务器
晚秋大魔王3 小时前
OpenHarmony 开源鸿蒙南向开发——linux下使用make交叉编译第三方库——wget
java·linux·运维·开发语言·华为·harmonyos
孤的心了不冷3 小时前
【Linux】Linux安装并配置MongoDB
linux·运维·mongodb·容器
南棱笑笑生3 小时前
20250517让NanoPi NEO core开发板在Ubuntu core16.04.2下支持TF卡的热插拔
linux·运维·ubuntu
jinlei20094 小时前
配置ssh服务-ubuntu到Windows拷贝文件方法
运维·ubuntu·ssh