Linux (in my case Ubuntu 14.04 Server))
设置在詹金斯配置环境变量
(Manage Jenkins -> Configure System -> Global properties -> Environment variables:
name=PATH, value=$PATH:$COMPOSER_HOME/vendor/bin/)解决了这个问题。
$ echo $COMPOSER_HOME/usr/share/.composer
请注意,
$COMPOSER_HOME不应将/不应将其设置为(root)用户(例如
/root/.composer)的子文件夹,因为它可能导致权限
问题:
Execute failed: java.io.IOException: Cannot run program “phpcs”: error=13,
Permission denied
Windows (在我的情况下为Windows Server 2008 r2)
除了设置Composer路径外,还
需要一些其他步骤:
首先我得到了错误
Execute failed: java.io.IOException: Cannot run program “phpcs”: error=2,
The system cannot find file specified
在我阅读的论坛上,目标需要获取可执行文件的路径,
如下所示:
<target name="phpcs"> <exec executable="C:pathtoComposervendorbinphpcs" taskname="phpcs"> <arg value="--standard=PSR2" /> <arg value="--extensions=php" /> <arg value="--ignore=autoload.php" /> <arg path="${basedir}/module/" /> </exec></target>
But it didn’t work and only causes the next error:
D:pathtobuild.xml:34: Execute failed: java.io.IOException: Cannot run
program “C:pathtoComposervendorbinphpcs”: CreateProcess error=193, %1
is not a valid Win32 application
It’s not a Jenkins, but an Ant issue. The cause and the solution are described
on the Ant docu page for
Exec:
Windows Users
The
<exec>task delegates toRuntime.execwhich in turn apparently calls
::CreateProcess. It is the latter Win32 function that
defines the exact semantics of the call. In particular, if you do not put a
file extension on the executable, only “.EXE” files are looked for, not
“.COM”, “.CMD” or other file types listed in the environment variable
PATHEXT. That is only used by the shell.Note that .bat files cannot in general by executed directly. One normally
needs to execute the command shell executablecmdusing the/cswitch.…
So in my case the working target specification looks as follows:
<target name="phpcs"> <exec executable="cmd" taskname="phpcs"> <arg value="/c" /> <arg value="C:pathtoComposervendorbinphpcs" /> <arg value="--standard=PSR2" /> <arg value="--extensions=php" /> <arg value="--ignore=autoload.php" /> <arg path="${basedir}/module/" /> </exec></target>
From now the build was passing through. But there was still an issue with
phpcs:
phpcs: [phpcs] 'php' is not recognized as an internal or external command, [phpcs] operable program or batch file. [phpcs] Result: 1
This is easily fixed by adding
PHPto the
Pathenvironment variable in
Jenkins (
Manage Jenkins -> Configure System -> Global properties ->Environment variables):
That’s it. :)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)