Ant构建文件迁移Doctrine(要求是/否)

时间:2012-10-02 16:00:31

标签: php ant doctrine-orm jenkins zend-framework2

所以我在我的ant构建文件中有这个目标:

<target name="migrate" description="Migrate the database">
    <exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true">
        <arg line="migrations:migrate"/>
    </exec>
</target>

doctrine migrate命令在运行之前提出问题并期待是或否的答案。所以我的构建失败了:

richard@richard-desktop:~/projects/myproject$ ant migrate
Buildfile: /home/richard/projects/myproject/build.xml

migrate:
     [exec]                                                            
     [exec]                     Doctrine Migrations                    
     [exec]                                                            
     [exec] 
     [exec] 
     [exec] 
     [exec]                       
     [exec]   [RuntimeException]  
     [exec]   Aborted             
     [exec]                       
     [exec] 
     [exec] 
     [exec] migrations:migrate [--write-sql] [--dry-run] [--configuration[="..."]] [--db-configuration[="..."]] [version]
     [exec] 
     [exec] 
     [exec] WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)

BUILD FAILED
/home/richard/projects/myproject/build.xml:42: exec returned: 1

Total time: 0 seconds
richard@richard-desktop:~/projects/myproject$ 

如何让ant自动对该问题回答“是”,以便运行迁移?

1 个答案:

答案 0 :(得分:2)

实际上很容易:

<target name="migrate" description="Migrate the database">
    <exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true">
        <arg line="migrations:migrate --no-interaction"/>
    </exec>
</target>