def reviveResult = sh(returnStatus: true, script: 'revive -config revive.toml ./...') if (reviveResult != 0) { currentBuild.result = 'FAILURE' error("revive 代码校验未通过,终止流水线") } 不能终止流水线
时间: 2024-02-21 21:01:31 浏览: 28
您好,您的第一个问题是关于Jenkins Pipeline中不能终止流水线的问题。根据您提供的代码片段,这段代码的作用是执行revive命令来校验代码,并且如果校验未通过,则将当前构建的结果设置为“FAILURE”并抛出异常,但是并没有终止流水线的操作。
如果您想要在代码校验未通过时终止流水线,您可以使用Jenkins Pipeline提供的error函数来抛出异常并终止流水线。修改代码如下:
```
def reviveResult = sh(returnStatus: true, script: 'revive -config revive.toml ./...')
if (reviveResult != 0) {
error("revive 代码校验未通过,终止流水线")
}
```
这样,当revive命令校验未通过时,将会抛出异常并终止流水线。希望能够解决您的问题。
相关问题
try { sh 'revive -config revive.toml ./...' } catch (Exception e) { currentBuild.result = 'FAILURE' error("revive 代码校验未通过,终止流水线") } 不能终止流水线
如果您的 Jenkins 流水线在执行 revive 代码校验时出现错误,但是没有终止流水线,可能是因为 revive 命令返回了非零的退出码,导致 Jenkins 不认为此次执行是失败的。您可以通过设置 `sh` 命令的 `returnStatus` 参数为 `true`,并使用 `if` 语句判断命令是否执行成功来解决这个问题,具体步骤如下:
```
def reviveResult = sh(returnStatus: true, script: 'revive -config revive.toml ./...')
if (reviveResult != 0) {
currentBuild.result = 'FAILURE'
error("revive 代码校验未通过,终止流水线")
}
```
这里使用 `sh` 命令的 `returnStatus` 参数来设置返回命令的退出码而不是命令的输出结果。然后,使用 `if` 语句判断命令的退出码是否为 0。如果不是 0,则将当前流水线的结果设置为 FAILURE,并使用 `error` 函数抛出异常信息,以便在 Jenkins 控制台中显示错误信息。
请注意,这里使用的是 `def` 关键字来定义一个变量 `reviveResult`,以便在后续的判断语句中使用。
Revive- Go 使用
Revive-Go 是一个用于将 Oculus Rift 应用程序转换为 Windows Mixed Reality (WMR) 的开源项目。如果您想在 WMR 设备上使用 Oculus Rift 应用,可以使用 Revive-Go 进行转换。
以下是使用 Revive-Go 的步骤:
1. 首先,您需要在 Windows Mixed Reality 设备上安装 SteamVR。您可以在 Steam 上下载并安装 SteamVR。
2. 然后,您需要下载 Revive-Go。您可以从 GitHub 上下载最新版本的 Revive-Go。
3. 解压缩 Revive-Go 到任何文件夹中。
4. 启动 SteamVR。
5. 找到 Oculus 应用程序的安装文件(.exe 文件),并在 WMR 设备上运行它。
6. 在 Oculus 应用程序中,您可以使用 Revive-Go 工具栏中的“Inject”按钮将应用程序注入到 SteamVR 中。
7. 点击“Inject”按钮后,Revive-Go 将自动启动并将应用程序注入到 SteamVR 中。
8. 在 SteamVR 中,您可以找到已注入的 Oculus 应用程序,并在 WMR 设备上使用它。
请注意,Revive-Go 不是官方支持的工具,使用它可能会导致不稳定或错误的行为。使用 Revive-Go 时请小心,谨慎处理。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)