【问题标题】:How to fail Jenkins build (or mark it as unstable) if Symfony deprecation is found如果发现 Symfony 弃用,如何使 Jenkins 构建失败(或将其标记为不稳定)
【发布时间】:2021-11-17 00:42:39
【问题描述】:

我们正在将我们的代码从 Symfony 3 迁移到 Symfony 4.4,并希望确保不会在代码中添加新的弃用。

我们正在使用 phpunit-bridge,可以在 Jenkins 构建输出中看到所有弃用警告。

但是,如果发现任何 Symfony 弃用,有没有办法让 Jenkins 构建失败(或将其标记为不稳定)?确保在将代码迁移到单独的分支时不会向代码添加新的弃用。

【问题讨论】:

  • 提供有关如何运行 phpunit 测试的更多详细信息。如果您使用任何 bash 脚本运行测试,请检查其退出代码。

标签: symfony jenkins migration phpunit deprecation-warning


【解决方案1】:

您可以将 failOnWarning="true" 添加到您的 phpunit.xml 以在出现(弃用)警告时将测试标记为失败。

包含failOnWarning 的示例 xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
        bootstrap="tests/autoload.php"
        colors="true"
        failOnWarning="true" <!--Here it is-->
>
    <php>
        <server name="KERNEL_CLASS" value="App\Kernel"/>
        <server name="APP_ENV" value="test" force="true"/>
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="logFile=./var/log/deprecations.log"/>
    </php>
    <testsuites>
        <testsuite name="unit">
            <directory>./tests/Unit</directory>
        </testsuite>
        <testsuite name="functional">
            <directory>./tests/Functional</directory>
        </testsuite>
        <testsuite name="integration">
            <directory>./tests/Integration</directory>
        </testsuite>
    </testsuites>
    <listeners>
        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
    </listeners>
</phpunit>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-03
    • 2012-11-20
    • 1970-01-01
    • 2020-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    相关资源
    最近更新 更多