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

相关推荐
塔能物联运维24 分钟前
案例:塔能科技驱动河南某市政照明智慧升级
大数据·运维
Fanche40439 分钟前
SQL 语句基础(增删改查)
运维·数据库·sql·mysql·web安全·oracle
MXsoft6181 小时前
美信监控易:揭秘高效数据采集和数据分析双引擎
大数据·运维
张3蜂1 小时前
[Jenkins]pnpm install ‘pnpm‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
运维·jenkins
励志成为大佬的小杨1 小时前
linux常见指令
linux·运维·服务器
汐汐咯1 小时前
vscode连接windows服务器出现过程试图写入的管道不存在
运维·服务器
APItesterCris2 小时前
Python + 淘宝 API 开发实战:自动化采集商品详情与 SKU 数据清洗指南
大数据·运维·数据库·自动化
Mr_Chenph2 小时前
Jenkins 2.492.3 Docker 速配
运维·jenkins
laimaxgg3 小时前
Docker华为云创建私人镜像仓库
运维·服务器·docker·容器·华为云
南川琼语4 小时前
Linux——共享内存
linux·运维·服务器