单元测试在本地工作,但不适用于Jenkins

时间:2018-03-01 12:35:26

标签: php docker jenkins build devops

现在已经敲了好几个小时。我刚刚开始使用Docker,并构建系统。我有一个PHP Codeception(单元测试框架)代码库作为repo示例。在本地,我能够成功运行测试,但是当我签入我的代码并进入CI(Jenkins)时,可以调用客户端程序但是没有找到测试。

* note 我知道我的构建定义可以使用一些工作,我的目标只是获得有效的构建。

Dockerfile

FROM codeception/codeception

生成文件

APP_NAME=codeception
ROOT_DIR=${PWD}
WORK_DIR=app

    docker_build:
        docker build -t $(APP_NAME) .

    run_test:
        docker run --rm --name ception -w /$(WORK_DIR) -v $(ROOT_DIR):/$(WORK_DIR) $(APP_NAME) run acceptance

仅仅为了论证,这就是它在构建系统中打印的方式

docker run --rm --name ception -w /app -v /var/jenkins_home/workspace/codeception:/app codeception run

构建触发器

make docker_build
make run_test

本地输出

OK (1 test, 0 assertions)

Jenkins输出

*注意没有失败,但是..

no tests executed!

Jenkins安装

主机是数字海洋上的Docker机器小滴,我运行了一个Jenkins容器,正在运行Docker sock,因此我可以在构建触发器上调用Docker

另一个问题

给出命令的上述前提条件:

*请注意pwd

docker run --rm --name ception -w /app -v /var/jenkins_home/workspace/codeception:/app codeception run; pwd

詹金斯输出:

/var/jenkins_home/workspace/codeception

我希望它输出/app,因为我的理解是,它从docker容器中调用pwd,所以这应该超出了/app目录。我现在很困惑

日志:

Started by GitHub push by edsk3o
Building in workspace /var/jenkins_home/workspace/codeception
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/edsk3o/codeception.git # timeout=10
Fetching upstream changes from https://github.com/edsk3o/codeception.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://github.com/edsk3o/codeception.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 1a7dd08ef1ed9e8e7b3f236c50690b65c65f37e8 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 1a7dd08ef1ed9e8e7b3f236c50690b65c65f37e8
Commit message: "laksjd"
 > git rev-list --no-walk 528640c7be393aaa06f94edc80f12234a759efd6 # timeout=10
[codeception] $ /bin/sh -xe /tmp/jenkins9213645655529951332.sh
+ make docker_build
docker build -t codeception .
Sending build context to Docker daemon  3.408MB

Step 1/1 : FROM codeception/codeception
 ---> 1681da57f253
Successfully built 1681da57f253
Successfully tagged codeception:latest
+ make run_test
docker run --rm --name ception -w /app -v /var/jenkins_home/workspace/codeception:/app codeception run acceptance; pwd
Codeception PHP Testing Framework v2.3.8
Powered by PHPUnit 6.5.6 by Sebastian Bergmann and contributors.

[1mAcceptance Tests (0) [22m---------------------------------------
------------------------------------------------------------


Time: 89 ms, Memory: 10.00MB

[30;43mNo tests executed![0m
/var/jenkins_home/workspace/codeception
Finished: SUCCESS

0 个答案:

没有答案