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 中间用空格隔开

相关推荐
Yyyy48225 分钟前
Nginx负载均衡集群实验步骤
运维·nginx·负载均衡
獭.獭.2 小时前
Linux -- 信号【上】
linux·运维·服务器
hashiqimiya2 小时前
centos配置环境变量jdk
linux·运维·centos
路由侠内网穿透3 小时前
本地部署 GPS 跟踪系统 Traccar 并实现外部访问
运维·服务器·网络·windows·tcp/ip
傻傻虎虎5 小时前
【Docker】常用帮忙、镜像、容器、其他命令合集(2)
运维·docker·容器
ZERO_pan6 小时前
服务器装机遇到的问题
运维·服务器
杀气丶6 小时前
Linux下运行芙蕾雅天堂2【俄文简译L2FATER】
运维·服务器·天堂2·l2fater·l2fater.cn
太空的旅行者7 小时前
告别双系统——WSL2+UBUNTU在WIN上畅游LINUX
linux·运维·ubuntu
九章云极AladdinEdu8 小时前
超参数自动化调优指南:Optuna vs. Ray Tune 对比评测
运维·人工智能·深度学习·ai·自动化·gpu算力
人工智能训练师9 小时前
Ubuntu22.04如何安装新版本的Node.js和npm
linux·运维·前端·人工智能·ubuntu·npm·node.js