Я новичок в настройке конвейера CI CD для моего приложения nodejs с использованием облачной сборки GCP. Ниже приведены шаги, которые я сделал:
- Запись файла cloudbuild.yaml. Готово
- Зеркально отразил репозиторий bitbucket в моем репозитории исходного кода облака GCP. Готово
- Настроил триггеры Webhook в моем GCP. Готово
- Когда я набираю sh код, он срабатывает. Готово
Пакет Cloudbuild.yaml
steps:
- name: "node:8.13"
args: ["npm", "install"]
- name: "node:8.13"
args: ["npm", "test"]
- name: "node:8.13"
args: ["npm", "run", "build"]
- name: "gcr.io/cloud-builders/gcloud"
args: ['functions', 'deploy', '[job_scheduling]', '--source=.', '--runtime', '[nodejs8.17]', '--trigger-http', '--allow-unauthenticated', '--entry-point=App']
. json:
{
"name": "groups",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"test": "mocha test/GET.js test/POST.js test/PUT.js test/DELETE.js",
"coverage":"nyc --reporter=text --reporter=lcov mocha test/GET.js test/POST.js test/PUT.js test/DELETE.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"firebase-admin": "^8.9.1",
"is-my-json-valid": "^2.20.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^7.0.1",
"nyc": "^15.0.0",
"supertest": "^4.0.2"
}
}
Когда я пу sh код в моем хранилище битовых корзин, сборка запускается, и я получаю следующие журналы:
starting build "43d640c7-159e-45d2-9d69-af1c03892f8e"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/emc-ema-cp-d-267406/r/bitbucket_zebraema_customer_portal
* branch 5f57724022fffa3b874c8929f410f3249eedeab8 -> FETCH_HEAD
HEAD is now at 5f57724 cloudbuild.yaml edited online with Bitbucket
BUILD
Starting Step #0
Step #0: Pulling image: node:8.13
Step #0: 8.13: Pulling from library/node
Step #0: 54f7e8ac135a: Pulling fs layer
Step #0: d6341e30912f: Pulling fs layer
Step #0: 087a57faf949: Pulling fs layer
Step #0: 5d71636fb824: Pulling fs layer
Step #0: 0c1db9598990: Pulling fs layer
Step #0: 89669bc2deb2: Pulling fs layer
Step #0: 4c84cd37194c: Pulling fs layer
Step #0: a8061553ef43: Pulling fs layer
Step #0: 5d71636fb824: Waiting
Step #0: 0c1db9598990: Waiting
Step #0: 89669bc2deb2: Waiting
Step #0: 4c84cd37194c: Waiting
Step #0: a8061553ef43: Waiting
Step #0: 087a57faf949: Verifying Checksum
Step #0: 087a57faf949: Download complete
Step #0: d6341e30912f: Verifying Checksum
Step #0: d6341e30912f: Download complete
Step #0: 54f7e8ac135a: Verifying Checksum
Step #0: 54f7e8ac135a: Download complete
Step #0: 89669bc2deb2: Verifying Checksum
Step #0: 89669bc2deb2: Download complete
Step #0: 5d71636fb824: Verifying Checksum
Step #0: 5d71636fb824: Download complete
Step #0: a8061553ef43: Verifying Checksum
Step #0: a8061553ef43: Download complete
Step #0: 4c84cd37194c: Verifying Checksum
Step #0: 4c84cd37194c: Download complete
Step #0: 0c1db9598990: Verifying Checksum
Step #0: 0c1db9598990: Download complete
Step #0: 54f7e8ac135a: Pull complete
Step #0: d6341e30912f: Pull complete
Step #0: 087a57faf949: Pull complete
Step #0: 5d71636fb824: Pull complete
Step #0: 0c1db9598990: Pull complete
Step #0: 89669bc2deb2: Pull complete
Step #0: 4c84cd37194c: Pull complete
Step #0: a8061553ef43: Pull complete
Step #0: Digest: sha256:3ecf259bf23f8a75555cf0b92ac5ad3c746e7e2262e937a9bed9ca1685f8e1c7
Step #0: Status: Downloaded newer image for node:8.13
Step #0: docker.io/library/node:8.13
Step #0: npm WARN saveError ENOENT: no such file or directory, open '/workspace/package.json'
Step #0: npm notice created a lockfile as package-lock.json. You should commit this file.
Step #0: npm WARN enoent ENOENT: no such file or directory, open '/workspace/package.json'
Step #0: npm WARN workspace No description
Step #0: npm WARN workspace No repository field.
Step #0: npm WARN workspace No README data
Step #0: npm WARN workspace No license field.
Step #0:
Step #0: up to date in 0.447s
Step #0: found 0 vulnerabilities
Step #0:
Finished Step #0
Starting Step #1
Step #1: Already have image: node:8.13
Step #1: npm ERR! path /workspace/package.json
Step #1: npm ERR! code ENOENT
Step #1: npm ERR! errno -2
Step #1: npm ERR! syscall open
Step #1: npm ERR! enoent ENOENT: no such file or directory, open '/workspace/package.json'
Step #1: npm ERR! enoent This is related to npm not being able to find a file.
Step #1: npm ERR! enoent
Step #1:
Step #1: npm ERR! A complete log of this run can be found in:
Step #1: npm ERR! /builder/home/.npm/_logs/2020-04-15T18_49_03_616Z-debug.log
Finished Step #1
ERROR
ERROR: build step 1 "node:8.13" failed: step exited with non-zero status: 254
Пожалуйста, помогите мне решить эту проблему.
Обновление: Когда я запускаю ваш код:
steps:
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: "ls"
args: ["-la", "/workspace"]
Ниже приведены журналы:
[![starting build "363526b2-37f7-4b5a-9ee6-599db1442933"
FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/emc-ema-cp-d-267406/r/bitbucket_zebraema_customer_portal
* branch 98a8af215a8e683f94558a6351af60512b6fa1d7 -> FETCH_HEAD
HEAD is now at 98a8af2 cloudbuild.yaml edited online with Bitbucket
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
total 20
drwxr-xr-x 5 root root 4096 Apr 16 14:17 .
drwxr-xr-x 1 root root 4096 Apr 16 14:17 ..
drwxr-xr-x 8 root root 4096 Apr 16 14:17 .git
drwxr-xr-x 15 root root 4096 Apr 16 14:17 API
drwxr-xr-x 4 root root 4096 Apr 16 14:17 UI
PUSH
DONE][1]][1]
Я приложил скриншот структуры моего проекта.