Node.js CircleCI can';“t运行”;克劳迪娅更新“;
我正在运行CircleCI和Claudia.js将我的node.js代码部署到AWS Lambda 以下是my package.json(脚本部分): 当我跑步时:Node.js CircleCI can';“t运行”;克劳迪娅更新“;,node.js,amazon-web-services,aws-lambda,circleci,claudiajs,Node.js,Amazon Web Services,Aws Lambda,Circleci,Claudiajs,我正在运行CircleCI和Claudia.js将我的node.js代码部署到AWS Lambda 以下是my package.json(脚本部分): 当我跑步时: npm run update 在终端,我可以很好地更新。但当我在CircleCI运行这个时,它失败了 这是我的CircleCI配置文件(.CircleCI/config.yml): CircleCI中的错误是: #!/bin/bash -eo pipefail npm run update > xxx@0.1.0 upda
npm run update
在终端,我可以很好地更新。但当我在CircleCI运行这个时,它失败了
这是我的CircleCI配置文件(.CircleCI/config.yml):
CircleCI中的错误是:
#!/bin/bash -eo pipefail
npm run update
> xxx@0.1.0 update /home/circleci/project
> claudia update
loading Lambda config
loading Lambda config lambda.getFunctionConfiguration FunctionName=xxx
loading Lambda config lambda.setupRequestListeners
{ CredentialsError: Missing credentials in config
at IncomingMessage.<anonymous> (/home/circleci/project/node_modules/aws-sdk/lib/util.js:864:34)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
message: 'Missing credentials in config',
retryable: false,
time: 2017-06-21T08:02:53.894Z,
code: 'CredentialsError',
originalError:
{ message: 'Could not load credentials from any providers',
retryable: false,
time: 2017-06-21T08:02:53.894Z,
code: 'CredentialsError' } }
编辑:
更改config.yml以匹配CircleCI 2.0的配置
与以前一样,除了凭据之外,其他一切都正常工作
来自CircleCI的日志文件:
我必须在AWS中的某个地方添加凭据吗?我仍然可以使用终端进行部署。您是否将creds存储在存储库中提到的文件中?首先,您可能不应该这样做,这是一个安全问题。如果您是,它需要位于
~/.aws/credentials
。根据您当前的配置,您的整个repo位于~/emailservice
的构建中。您需要创建aws
目录,然后使用mv
移动creds。比如:
mkdir ~/.aws
mv ~/emailservice/my-creds-file ~/.aws/credenials
或者,我建议您不要在回购协议中使用文件。在这种情况下,您需要在CircleCI的web UI中设置变量AWS\u ACCESS\u KEY\u ID
和AWS\u SECRET\u ACCESS\u KEY
。AWS CLI将在运行时查看并使用这些凭据
可以在以下位置找到AWS CLI身份验证方法:
恭敬地
里卡多·费利西亚诺CircleCI开发者福音传道者
原始答复: 我不是100%确定你所犯错误的确切原因,但看起来你有一个更大的问题。该配置文件看起来根本不正确。CircleCI 1.0和2.0中的概念和配置语法以不兼容的方式混合在一起。我将在上检查配置语法,并选择要使用哪个版本的CircleCI
之后,要么在这里,要么我们可以尝试排除故障。这可能与CircleCI处理用户的方式有关 我建议使用环境变量来存储AWS访问密钥和密码 您需要添加以下环境变量:
AWS\u访问\u密钥\u ID
-使用您的访问密钥作为值AWS\u SECRET\u ACCESS\u KEY
-使用您的密钥作为值
有关通过AWS中的环境变量设置密钥的更多信息:有关Circle CI中环境变量的更多信息:
谢谢您的快速回答,我会检查一下文档,如果我不解决问题,会给您回复。如果出现进一步的问题,我们是否应该在这里进行讨论?谢谢,我已经编辑了我的配置文件,除了原来的问题,一切正常。凭据错误。我将用我的新配置文件编辑我的问题。谢谢,我将试一试!这似乎有效,但我有一个新问题。我会继续寻找答案。坦斯克!有什么问题吗?请随便问,我是克劳迪亚队的。另外,对于克劳迪娅相关的问题,你应该查看我们的gitter,即那里的post stackoverflow链接,有人会跳进去尝试回答。
#!/bin/bash -eo pipefail
npm run update
> xxx@0.1.0 update /home/circleci/project
> claudia update
loading Lambda config
loading Lambda config lambda.getFunctionConfiguration FunctionName=xxx
loading Lambda config lambda.setupRequestListeners
{ CredentialsError: Missing credentials in config
at IncomingMessage.<anonymous> (/home/circleci/project/node_modules/aws-sdk/lib/util.js:864:34)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
message: 'Missing credentials in config',
retryable: false,
time: 2017-06-21T08:02:53.894Z,
code: 'CredentialsError',
originalError:
{ message: 'Could not load credentials from any providers',
retryable: false,
time: 2017-06-21T08:02:53.894Z,
code: 'CredentialsError' } }
[claudia]
aws_access_key_id = xxxxxxx
aws_secret_access_key = xxxxxx
version: 2
jobs:
build:
working_directory: ~/emailservice
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm run test
- store_artifacts:
path: test-results.xml
prefix: tests
- store_artifacts:
path: coverage
prefix: coverage
- store_test_results:
path: test-results.xml
- run:
name: deploy_update
command: npm run update
loading Lambda config
loading Lambda config lambda.getFunctionConfiguration FunctionName=emailService
loading Lambda config lambda.setupRequestListeners
{ [CredentialsError: Missing credentials in config]
message: 'Missing credentials in config',
code: 'CredentialsError',
time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
retryable: true,
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
retryable: true,
originalError:
{ message: 'Connection timed out after 1000ms',
code: 'TimeoutError',
time: Thu Jun 22 2017 08:11:27 GMT+0000 (UTC),
retryable: true } } }
npm info lifecycle xxx_email_service@0.2.0~update: Failed to exec update script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxx_email_service@0.2.0 update: `claudia update`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxx_email_service@0.2.0 update script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2017-06-22T08_11_27_089Z-debug.log
Exited with code 1
mkdir ~/.aws
mv ~/emailservice/my-creds-file ~/.aws/credenials