我有一个运行良好的 Dockerfile:
FROM node:10
RUN npm set unsafe-perm true
RUN npm install -g '@oresoftware/r2g@0.0.132'
Run Code Online (Sandbox Code Playgroud)
但是与上述 Dockerfile 相同的 CircleCI config.yml 文件不起作用:
{
"version": 2,
"jobs": {
"build": {
"docker": [
{
"image": "circleci/node:10"
}
],
"steps": [
{
"run": "npm set unsafe-perm true"
},
{
"run": "npm install -g --loglevel=warn '@oresoftware/r2g@0.0.132'"
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用上面的 config.yml 文件在 CircleCI 上收到以下错误:
#!/bin/bash -eo pipefail
npm install -g --loglevel=warn @oresoftware/r2g
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules …
Run Code Online (Sandbox Code Playgroud) 对于我的项目,我正在尝试从 GitHub Packages 安装(而不是发布!)一个 npm 包。它托管在组织中的私有存储库上。我已经制作了一个个人访问令牌,具有从该 repo 和 org 读取所需的权限。所有这些都可以通过以下步骤在本地工作:
.npmrc
文件中设置注册表:registry=https://npm.pkg.github.com/OWNER
npm login --registry=https://npm.pkg.github.com
然后会提示:> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
Run Code Online (Sandbox Code Playgroud)
Username
是你的标准 github 用户名Token
是使用正确权限创建的个人访问令牌Email
可以是随机的填写完成后,一切正常,我可以安装该包,以及托管在普通 npm 注册表中的所有其他包。现在问题来了:我试图在 circleCI 上复制相同的内容,但它似乎并没有让我覆盖 npm 注册表。该项目在.npmrc
其所在的同一文件夹中包含一个文件package.json
。这是圆 ci conf 的一部分:
- run:
name: "Set NPM registry"
command: npm config set registry https://npm.pkg.github.com/OWNER
- run:
name: "Authenticate with GitHub package registry"
command: echo "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES}" > web_ui/frontend/.npmrc
- …
Run Code Online (Sandbox Code Playgroud) We are trying to cache all Gradle dependencies for our Android build
job.
This is the current approach that is failing:
- restore_cache:
key: android-build-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
- save_cache:
paths:
- ~/.gradle
key: android-build-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
Run Code Online (Sandbox Code Playgroud) 我遇到一个问题,当运行邮件程序的第一次测试时,当第一次调用ActionMailer::Base#mail方法时,测试会挂起并需要大约 10 分钟。有人经历过这个吗?
CircleCi 图像:图像:circleci/ruby:2.4.3-node
我的测试
class Notifier::AccountMailer < NotifierMailer
def welcome(user_id)
@user = User.find user_id
mail(to: @user.email, subject: t('subject.welcome'))
end
end
RSpec.describe Notifier::AccountMailer, type: :mailer do
describe '.welcome' do
let(:user) { build_stubbed(:user) }
let(:mail) { described_class.welcome(1) }
before { allow(User).to receive(:find).and_return(user) }
it 'Send from <notify@my-server.me>' do
expect(mail.from).to eq(['notify@my-server.me'])
end
it 'Send to account e-mail' do
expect(mail.to).to eq([user.email])
end
end
end
Run Code Online (Sandbox Code Playgroud)
缓慢仅发生在一切正常后第一次调用邮件方法时。
是否可以在另一个作业的上下文中运行另一个作业?我的一些工作有一些共同的步骤,我不想在不同的工作中重复这些步骤。
push-production-image:
docker:
- image: google/cloud-sdk:latest
working_directory: ~/app
steps:
- setup-gcp-docker
- run: docker push [image]
Run Code Online (Sandbox Code Playgroud) MAX_CONNECTIONS
我正在努力在 CircleCI 配置文件中配置postgres 配置。正如您在下面看到的,我尝试使用sed
替换 max_connections 值,但这没有做任何事情, max_connections 保持为默认值100
。我还尝试运行自定义命令(请参阅command: |
下面的注释块),但这引发了以下错误并停止了circleCI进程:/docker-entrypoint.sh: line 100: exec: docker: not found Exited with code 127
version: 2
jobs:
test:
pre:
- sudo sed -i 's/max_connections = 100/max_connections = 300/g' /etc/postgresql/9.6/main/postgresql.conf # Allow more than 100 connections to DB
- sudo service postgresql restart
docker:
# Specify the version you desire here
- image: circleci/node:8.11
# Setup postgres and configure the db
- image: hegand/postgres-postgis
# command: |
# …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试使用commands
CircleCI 2.1 版中可用的功能,以便我可以重用一些常用命令。我正在使用 CLI 命令进行测试:
circleci config process ./.circleci/config.latest.yaml > ./.circleci/config.yml
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Error: Error calling workflow: 'main'
Error calling job: 'build'
Error calling command: 'build_source'
Cannot find a definition for command named restore-cache
Run Code Online (Sandbox Code Playgroud)
似乎restore-cache
在直接版本 2 配置文件中工作得很好,但是当我尝试使用process
它处理 2.1 文件时,它会大惊小怪。
以下是我的config.yaml
文件的编辑版本,希望能有所帮助。如果有任何有用的其他信息,请告诉我。
version: 2.1
defaults: &defaults
/**
* Unimportant stuff
*/
aliases:
- &restore-root-cache
keys:
- v1-deps-{{ .Branch }}-{{ checksum "package.json" }}
- v1-deps-{{ .Branch }}
- v1-deps
commands:
build_source:
description: 'Installs dependencies, then builds …
Run Code Online (Sandbox Code Playgroud) continuous-integration circleci circleci-workflows circleci-2.0
如果我有这样的.circleci/config.yml
文件:
version: 2
jobs:
build-node8:
docker:
- image: oresoftware/lmx-circleci:8
steps:
- checkout
- run: ./scripts/circleci/run.sh
build-node9:
docker:
- image: oresoftware/lmx-circleci:9
steps:
- checkout
- run: ./scripts/circleci/run.sh
build-node10:
docker:
- image: oresoftware/lmx-circleci:10
steps:
- checkout
- run: ./scripts/circleci/run.sh
build-node11:
docker:
- image: oresoftware/lmx-circleci:11
steps:
- checkout
- run: ./scripts/circleci/run.sh
build-node12:
docker:
- image: oresoftware/lmx-circleci:12
steps:
- checkout
- run: ./scripts/circleci/run.sh
Run Code Online (Sandbox Code Playgroud)
这里列出了 5 个作业,但是当构建开始时,只有 4 个作业并行运行。有没有办法并行运行 4 个以上的作业,那里有硬性限制吗?
我的猜测是在工作流下,我可以更改并行级别?
workflows:
version: 2
build_nodejs:
parallelism: 5
jobs:
- build-node8
- build-node9 …
Run Code Online (Sandbox Code Playgroud) 在过去的两天里,我一直在寻找使用 Expo + Detox + CircleCI 的良好设置,以便应用程序可以在 CI 过程中构建。
在本地,我可以通过下载 Exponent.app 并放入 bin 并运行 expo start(在不同的终端中)来使 Expo + Detox 工作。然而,expo start 在 Circle CI 中是阻塞的,所以有没有一种有效的方法来实现这一点。
我查看了很多示例,但没有找到一个带有更新示例的明确回应,考虑到 Expo 的受欢迎程度,这是一种耻辱。
如果有人有您可以共享的示例 CircleCI 文件,那就太好了!或者确实有助于解释实现这一目标的流程。
我很欣赏这也是 Detox 和 CircleCI 的问题,但我想我会在这里添加它,因为许多人可能也想知道答案?
我目前的 Circle-CI 代码,我一直在试图找到一个有效的解决方案来来回回...
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
defaults: &defaults
working_directory: ~/iynk-react-app
jobs:
test:
<<: *defaults
docker:
- image: circleci/node:10
steps:
- checkout
- run:
name: Update npm
command: 'sudo npm install …
Run Code Online (Sandbox Code Playgroud) 我在 CircleCI 中运行黄瓜测试时遇到问题,因为 CSS 文件未正确加载。
我在测试环境中运行了该项目RAILS_ENV=test rails s
,但它没有加载 CSS(尽管我可以看到由 生成的 CSS RAILS_ENV=test rake assets:precompile
)。只有我之前运行它才会正确加载rake assets:precompile
。但是我该如何为circleCI 做到这一点呢?
同样,在本地我可以运行bundle exec cucumber
而不会出现任何失败的测试(如果我rake assets:precompile
之前运行过),但是如果我随后使用 CircleCI 运行相同的测试,我会得到相同的失败测试,就像删除文件public/assets
夹并bundle exec cucumber
在本地运行一样。
在我的文件中environment/test.rb
,我已将文件添加到config.assets.precompile
这是我的applicatin.scss
:
/*
*= require_self
*= require_tree ./shared
*= require_tree ./tenants
*= require_tree ./pages
*/
Run Code Online (Sandbox Code Playgroud)
我的Gemfile
:
ruby '2.5.5'
source 'https://rubygems.org'
gem 'rails', '5.2'
gem 'bootstrap-sass'
gem 'coffee-rails'
gem 'haml-rails', "~> 1.0"
gem 'jquery-rails'
gem 'd3_rails'
gem …
Run Code Online (Sandbox Code Playgroud) circleci-2.0 ×10
circleci ×9
android ×1
detox ×1
docker ×1
email ×1
expo ×1
github ×1
node.js ×1
npm ×1
postgresql ×1
react-native ×1
rspec ×1
testing ×1