如何在本地测试对 Jenkinsfile 所做的更改? [英] How can I test a change made to Jenkinsfile locally?

查看:17
本文介绍了如何在本地测试对 Jenkinsfile 所做的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写 jenkins 管道时,提交每个新更改以查看它是否有效似乎非常不方便.

有没有办法在不提交代码的情况下在本地执行这些?

解决方案

你不能在本地执行 Pipeline 脚本,因为它的全部目的是编写 Jenkins 脚本.(这就是为什么最好保持 Jenkinsfile 简短并仅限于实际处理 Jenkins 功能的代码的原因之一;您的实际构建逻辑应该由您通过调用的外部进程或构建工具处理一行 shbat 步骤.)

如果您想实时测试对 Jenkinsfile 的更改但不提交,请使用 1.14 中添加的重播功能

JENKINS-33925 跟踪所需的自动化测试框架.p>

When writing jenkins pipelines it seems to be very inconvenient to commit each new change in order to see if it works.

Is there a way to execute these locally without committing the code?

解决方案

You cannot execute Pipeline script locally, since its whole purpose is to script Jenkins. (Which is one reason why it is best to keep your Jenkinsfile short and limited to code which actually deals with Jenkins features; your actual build logic should be handled with external processes or build tools which you invoke via a one-line sh or bat step.)

If you want to test a change to Jenkinsfile live but without committing it, use the Replay feature added in 1.14

JENKINS-33925 tracks the desired for an automated test framework.

这篇关于如何在本地测试对 Jenkinsfile 所做的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆