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

相关推荐
东林牧之6 分钟前
CICD[导航]、docker+gitlab+harbor+jenkins从安装到部署
docker·gitlab·jenkins
小林up15 分钟前
github push:ssh: connect to host github.com port 22
运维·ssh·github
梁bk3 小时前
[Nginx]反向代理和负载均衡
运维·nginx·负载均衡
(:满天星:)9 小时前
第31篇:块设备与字符设备管理深度解析(基于OpenEuler 24.03)
linux·运维·服务器·网络·centos
小陶来咯9 小时前
【仿muduo库实现并发服务器】Acceptor模块
运维·服务器
cui_hao_nan9 小时前
Docker后端部署
运维·docker·容器
ZZH1120KQ10 小时前
Linux系统安全及应用
linux·运维·系统安全
小扎仙森10 小时前
关于服务器宝塔转移wordperss子比主题问题
运维·服务器
小小小糖果人10 小时前
Linux云计算基础篇(5)
linux·运维·服务器
我不是哆啦A梦10 小时前
破解风电运维“百模大战”困局,机械版ChatGPT诞生?
运维·人工智能·python·算法·chatgpt