我们如何在 Gitlab 中不生成退出代码的情况下继续执行下一个脚本 CI

How do we proceed to the next script with previous script not generating an exit code in Gitlab CI

我有一种情况,其中一个脚本将应用程序部署到本地主机上,但没有任何退出代码,之后我的测试需要 运行 访问该应用程序。下面是我的 yaml -

    test-e2e-mac:
  stage: test
  cache:
    <<: *global_cache
    policy: pull
  tags:
    - mac-p
  script:
    - yarn install && yarn build && yarn workspace sandbox dev
    - yarn run test:e2e

命令 yarn workspace sandbox dev 将应用程序部署到本地主机但没有任何退出代码,因此作业卡在那里而不是继续执行下一个脚本 yarn run test:e2e

下面是日志输出-

$ yarn install && yarn build && yarn workspace sandbox dev
➤ YN0000: ┌ Resolution step
Resolution step
00:00
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
Fetch step
00:01
➤ YN0000: └ Completed in 1s 96ms
➤ YN0000: ┌ Link step
Link step
00:15
➤ YN0000: └ Completed in 15s 241ms
➤ YN0000: Done with warnings in 16s 724ms
➤ YN0000: [build:*css] yarn run build:css exited with code 0
➤ YN0000: [build:*js] yarn run build:js exited with code 0
➤ YN0000: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
➤ YN0000: Attention: Next.js now collects completely anonymous telemetry regarding usage.
➤ YN0000: This information is used to shape Next.js' roadmap and prioritize features.
➤ YN0000: You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
➤ YN0000: https://nextjs.org/telemetry
➤ YN0000: 
➤ YN0000: info  - Checking validity of types...
➤ YN0000: info  - Creating an optimized production build...
➤ YN0000: info  - Compiled successfully
➤ YN0000: info  - Collecting page data...
➤ YN0000: info  - Generating static pages (0/3)
➤ YN0000: info  - Generating static pages (3/3)
➤ YN0000: info  - Finalizing page optimization...
➤ YN0000: 
➤ YN0000: Page                                       Size     First Load JS
➤ YN0000: ┌ ○ /                                      14.2 kB        85.6 kB
➤ YN0000: ├   └ css/01242c01debb6154.css             1.06 kB
➤ YN0000: ├   /_app                                  0 B            71.5 kB
➤ YN0000: └ ○ /404                                   193 B          71.6 kB
➤ YN0000: + First Load JS shared by all              71.5 kB
➤ YN0000:   ├ chunks/framework-c4190dd27fdc6a34.js   42 kB
➤ YN0000:   ├ chunks/main-bb9def7d8910e0b5.js        28.1 kB
➤ YN0000:   ├ chunks/pages/_app-0a7fb017d9a7d5bb.js  507 B
➤ YN0000:   ├ chunks/webpack-5023c8273a18d257.js     780 B
➤ YN0000:   └ css/653c6652631f0700.css               876 B
➤ YN0000: 
➤ YN0000: ○  (Static)  automatically rendered as static HTML (uses no initial props)
➤ YN0000: 
➤ YN0000: info  - using build directory: /Users/ppami/builds/i2gVvArX/0/dolby-io-sdk/spider-man/apps/sandbox/.next
➤ YN0000: info  - Copying "static build" directory
➤ YN0000: info  - No "exportPathMap" found in "/Users/ppami/builds/i2gVvArX/0/dolby-io-sdk/spider-man/apps/sandbox/next.config.js". Generating map from "./pages"
➤ YN0000: info  - Launching 9 workers
➤ YN0000: info  - Exporting (0/2)
➤ YN0000: info  - Copying "public" directory
➤ YN0000: info  - Exporting (2/2)
➤ YN0000: Export successful. Files written to /Users/ppami/builds/i2gVvArX/0/dolby-io-sdk/spider-man/apps/sandbox/out
➤ YN0000: error - ESLint: Failed to load plugin 'testcafe' declared in '../../.eslintrc.js': Cannot find module 'eslint-plugin-testcafe' Require stack: - /Users/ppami/builds/i2gVvArX/0/dolby-io-sdk/spider-man/__placeholder__.js Referenced from: /Users/ppami/builds/i2gVvArX/0/dolby-io-sdk/spider-man/.eslintrc.js
➤ YN0000: Done in 13s 678ms
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
event - compiled successfully in 1362 ms (175 modules)
ERROR: Job failed: execution took longer than 1h0m0s seconds

作业因超时而失败。我的应用程序已部署到 http://localhost:3000

这里有什么指示吗??

就像在您的本地系统上一样,运行 服务器将永远阻止。在服务器停止之前,您无法在终端中输入任何命令。

要在 GitLab CI 中解决这个问题,您可以将服务器任务置于后台以允许脚本的其余部分继续。在 bash 中,要使命令成为背景,请以 &.

结束命令
  script:
    - yarn install && yarn build 
    - yarn workspace sandbox dev &   # start server in the background
    - sleep 5 # give it a few seconds to start up!
    - yarn run test:e2e