2016-04-05 4 views
1

私はプロジェクトに取り組んでおり、ジェンキンスを使いたいと思っています。 configがfiew目標と簡単なbuild.xmlによって行われるべきである:COMPOSER_HOME/binのバイナリで動作するJenkinsを取得するには?

<?xml version="1.0" encoding="UTF-8"?> 
<project name="MyProject" default="full-build"> 
    <property name="phpcs" value="phpcs"/> 
    <property name="phpdox" value="phpdox"/> 
    <target name="full-build" depends="lint, phpdox" description="Performs static analysis, runs the tests, and generates project documentation"/> 
    <target name="lint" description="Perform syntax check of sourcecode files"> 
     <apply executable="php" taskname="lint" failonerror="true"> 
      <arg value="-l" /> 
      <fileset dir="${basedir}/module/"> 
       <include name="**/*.php" /> 
      </fileset> 
      <fileset dir="${basedir}/phpunit/tests"> 
       <include name="**/*.php" /> 
      </fileset> 
     </apply> 
    </target> 
    <target name="phpdox" description="Generate project documentation using phpDox"> 
     <exec executable="${phpdox}" dir="${basedir}/ci/phpdox" taskname="phpdox"/> 
    </target> 
</project> 

PHPリント(php -l)仕事は完璧に動作します:

コンソール出力

Started by user anonymous 
Building in workspace D:\Data\myproject 
> git.exe rev-parse --is-inside-work-tree # timeout=10 
Fetching changes from the remote Git repository 
> git.exe config remote.origin.url https://github.com/MyAccount/MyProject.git # timeout=10 
Fetching upstream changes from https://github.com/MyAccount/MyProject.git 
> git.exe --version # timeout=10 
using .gitcredentials to set credentials 
> git.exe config --local credential.username myusername # timeout=10 
> git.exe config --local credential.helper store --file=\"C:\Windows\TEMP\git8298647783094567497.credentials\" # timeout=10 
Setting http proxy: my.proxy.tld:8080 
> git.exe -c core.askpass=true fetch --tags --progress https://github.com/MyAccount/MyProject.git +refs/heads/*:refs/remotes/origin/* 
> git.exe config --local --remove-section credential # timeout=10 
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10 
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10 
Checking out Revision 54af2180160f47d518c42f58f56cba175ca2ee39 (refs/remotes/origin/master) 
> git.exe config core.sparsecheckout # timeout=10 
> git.exe checkout -f 54af2180160f47d518c42f58f56cba175ca2ee39 
> git.exe rev-list 54af2180160f47d518c42f58f56cba175ca2ee39 # timeout=10 
[myproject] $ cmd.exe /C '"ant.bat && exit %%ERRORLEVEL%%"' 
Buildfile: D:\Data\myproject\build.xml 

lint: 
    [lint] No syntax errors detected in D:\Data\myproject\module\Application\Module.php 
    ... 
    [lint] No syntax errors detected in D:\Data\myproject\phpunit\tests\Application\DummyTest.php 

しかしの実行しますPHPDoxが失敗しています:

phpdox: 

BUILD FAILED 
D:\Data\myproject\build.xml:18: Execute failed: java.io.IOException: Cannot run program "phpdox" (in directory "D:\Data\myproject\ci\phpdox"): CreateProcess error=2, The system cannot find the file specified 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) 
    at java.lang.Runtime.exec(Runtime.java:620) 
    at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58) 
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428) 
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442) 
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629) 
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670) 
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496) 
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
    at org.apache.tools.ant.Task.perform(Task.java:348) 
    at org.apache.tools.ant.Target.execute(Target.java:435) 
    at org.apache.tools.ant.Target.performTasks(Target.java:456) 
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405) 
    at org.apache.tools.ant.Project.executeTarget(Project.java:1376) 
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
    at org.apache.tools.ant.Project.executeTargets(Project.java:1260) 
    at org.apache.tools.ant.Main.runBuild(Main.java:853) 
    at org.apache.tools.ant.Main.startAnt(Main.java:235) 
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285) 
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112) 
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified 
    at java.lang.ProcessImpl.create(Native Method) 
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386) 
    at java.lang.ProcessImpl.start(ProcessImpl.java:137) 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) 
    ... 24 more 

Total time: 8 seconds 
Build step 'Invoke Ant' marked build as failure 
Finished: FAILURE 

globallyがインストールされており、COMPOSER_HOME/bin(例。 PHP_Codesniffer)。

別の方法でコマンドを定義しようとしましたが(<exec executable="cmd"><arg line="/c phpdox ..." /></exec>など)、動作しません。

build.xmlantで直接実行します。

Composerの環境変数が正しく設定されています - 私はCLI(CMDまたはGitBash/MinGW)を介してツールを呼び出すことができます。だから問題は他の何かによって引き起こされているに違いない。それは何でしょうか?

JenkinsがComposerを使用してグローバルにインストールされたパッケージで動作する方法を教えてください。

答えて

0

Linuxの(私の場合のUbuntu 14.04サーバー)

はジェンキンス構成(Manage Jenkins -> Configure System -> Global properties -> Environment variablesname=PATH, value=$PATH:$COMPOSER_HOME/vendor/bin/)での環境変数の設定は、問題を解決しました。

enter image description here

$ echo $COMPOSER_HOME 
/usr/share/.composer 

$COMPOSER_HOMEは/(root)ユーザ(例えばのサブフォルダに設定されなくてもよいように注意してください、/root/.composer)、それはpermission issues引き起こす可能性がありますので、:作曲パスの設定に加えて、いくつかのさらなるステップを

Execute failed: java.io.IOException: Cannot run program "phpcs": error=13, Permission denied


Windowsの()私の場合Windows Server 2008 R2で

は/必要とされました。私の

まずエラーを得た

Execute failed: java.io.IOException: Cannot run program "phpcs": error=2, The system cannot find file specified

01次のエラー

<target name="phpcs"> 
    <exec executable="C:\path\to\Composer\vendor\bin\phpcs" taskname="phpcs"> 
     <arg value="--standard=PSR2" /> 
     <arg value="--extensions=php" /> 
     <arg value="--ignore=autoload.php" /> 
     <arg path="${basedir}/module/" /> 
    </exec> 
</target> 

しかし、それは動作しませんでしたとだけ発生します:

D:\path\to\build.xml:34: Execute failed: java.io.IOException: Cannot run program "C:\path\to\Composer\vendor\bin\phpcs": CreateProcess error=193, %1 is not a valid Win32 application

をターゲットは次のように実行ファイルへのパスを取得する必要があることを私が読んフォーラムに

、これはJenkinsではなく、Antの問題です。原因と対策をAnt docu page for Execに説明されています

Windows Users

The <exec> task delegates to Runtime.exec which 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 executable cmd using the /c switch.

...

次のようにだから私の場合で働い目標仕様が見えます:

<target name="phpcs"> 
    <exec executable="cmd" taskname="phpcs"> 
     <arg value="/c" /> 
     <arg value="C:\path\to\Composer\vendor\bin\phpcs" /> 
     <arg value="--standard=PSR2" /> 
     <arg value="--extensions=php" /> 
     <arg value="--ignore=autoload.php" /> 
     <arg path="${basedir}/module/" /> 
    </exec> 
</target> 

今ビルドが通過してから。しかしphpcsでまだ問題がありました:

phpcs: 
    [phpcs] 'php' is not recognized as an internal or external command, 
    [phpcs] operable program or batch file. 
    [phpcs] Result: 1 

これは簡単ジェンキンス(Manage Jenkins -> Configure System -> Global properties -> Environment variables)にPath環境変数にPHPを追加することによって固定されている:それ

enter image description here

だこと。 :)

関連する問題