如何使用Jenkins Blue Ocean测试应用程序?

时间:2018-05-16 09:11:50

标签: reactjs jenkins github npm continuous-integration

使用create-react-app

创建了一个反应应用
$ npx create-react-app my-app-3

刚刚在其中添加了一个名为Jenkinsfile的文件

#!/usr/bin/env groovy

node('master') {
    try {
        stage('build') {
            sh "npm install"
        }

        stage('test') {
            sh "npm test"
        }
    } catch(error) {
        throw error
    } finally {

    }
}

将其推送到Github并添加Jenkins Blue Ocean的新管道

Jenkins Blue Ocean发现了上面创建的github repo。检查了一下。

然后它自动运行

运行npm test

时出错
[my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA] Running shell script

+ npm test

npm ERR! path /var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/package.json

npm ERR! code ENOENT

npm ERR! errno -2

npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open '/var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/package.json'

npm ERR! enoent This is related to npm not being able to find a file.

npm ERR! enoent 



npm ERR! A complete log of this run can be found in:

npm ERR!     /var/lib/jenkins/.npm/_logs/2018-05-16T08_57_26_292Z-debug.log

script returned exit code 254

/var/lib/jenkins/.npm/_logs/2018-05-16T08_57_26_292Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'test' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose stack Error: ENOENT: no such file or directory, open '/var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/package.json'
5 verbose cwd /var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA
6 verbose Linux 4.4.0-1052-aws
7 verbose argv "/usr/bin/node" "/usr/bin/npm" "test"
8 verbose node v8.11.1
9 verbose npm  v5.6.0
10 error path /var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/package.json
11 error code ENOENT
12 error errno -2
13 error syscall open
14 error enoent ENOENT: no such file or directory, open '/var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

我检查了此路径:/var/lib/jenkins/workspace/my-app-3_master-AOH6VCAOPUS4BCUQLNULA3ABCOUVZZEDO2LPJHNW3MX7M2F4KQIA/,仅存在package-lock.json但没有其他文件。所以它无法找到它们。为什么没有提取完整的文件?

0 个答案:

没有答案