【问题标题】:Jenkins execute shell詹金斯执行外壳
【发布时间】:2018-01-23 12:18:11
【问题描述】:

我有一个 jenkins 作业,它在作业执行 shell 中配置了 5 个构建脚本。现在我在脚本#1 中有一个标志,如果它是假的,那么我不想运行剩余的 4 个构建脚本并直接退出然后构建结果应该通过。

但是现在即使在检查 script#1 标志为 false 之后,它也会从 script#1 退出并执行剩余的 4 个构建脚本,然后由于与 script#1 的依赖,所有 4 个脚本都失败了,最后我的 jenkins 构建状态失败。

我希望在检查脚本#1 作业后可以退出并直接 jenkins 作业状态应该是“通过”

jenkins 本身是否有控制此流程的方法?不用在脚本中编写任何代码?

詹金斯错误:

------------
23:37:16 Nothing to build
23:37:16 SRV_SKIP_UNNECESSARY_BUILDS is set to 1
23:37:16 Exiting now...
23:37:16 +++/usr/atria/bin/cleartool rmview -f -tag swrel_sre_icx_test_ashok_diffreportvu_20180118_233612
23:37:30 SRE_FYI: No rebuild necessary for sre_icx_test_ashok since previous full build[EnvInject] - Injecting environment variables from a build step.
23:37:30 [EnvInject] - [ERROR] - The given properties file path '/var/tmp/jenkins/workspace/Test/sre_icx_test_ashok/srv_env_strip' doesn't exist.
23:37:30 [EnvInject] - [ERROR] - Missing file path was resolved from pattern '${WORKSPACE}/srv_env_strip' .
23:37:30 [EnvInject] - [ERROR] - Problems occurs on injecting env vars as a build step: java.io.IOException: remote file operation failed: /var/tmp/jenkins/workspace/Test/sre_icx_test_ashok at hudson.remoting.Channel@1c0be696:l42-up-ecbld-01: java.io.IOException: The given properties file path '/var/tmp/jenkins/workspace/Test/sre_icx_test_ashok/srv_env_strip' doesn't exist.
23:37:30 Build step 'Inject environment variables' changed build result to FAILURE
23:37:30 Build step 'Inject environment variables' marked build as failure
23:37:30 Set build name.
23:37:30 Unrecognized macro 'SRV_BUILD_LABEL' in '#22 - ${SRV_BUILD_LABEL}'
23:37:30 Archiving artifacts
23:37:30 SSH: Current build result is [FAILURE], not going to run.
23:37:30 [description-setter] Description set: ${SRV_BUILD_DIR}
23:37:30 Notifying upstream projects of job completion
23:37:30 Finished: FAILURE

【问题讨论】:

    标签: shell jenkins execute


    【解决方案1】:

    理论上,您可以通过获取一个名为“Fail The Build”的 Jenkins 插件并更改您的工作来做到这一点:

    • 第一个构建步骤将 flagvar=value 写入文件,该文件稍后可由另一个脚本获取,然后以失败退出。失败将跳过运行后续构建步骤并直接进入构建后操作。
    • 然后可以在构建后设置“执行一组脚本->构建步骤->执行shell”。将其设置为仅在构建失败时执行步骤,然后在第一步中让它获取第一个构建步骤的文件,以查看它是中止还是实际失败的构建。如果构建失败,则再次退出并出现错误 - 否则让它进入下一个构建后构建步骤,该步骤调用 Fail The Build 将作业状态更改回成功。

    我还没有尝试过,看看它是否真的有效。

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 2023-03-26
      • 1970-01-01
      • 2016-07-16
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      • 2012-10-01
      • 1970-01-01
      相关资源
      最近更新 更多