- 解析配置文件时出错:yaml:第 22 行:未找到预期的密钥
- 在配置文件的部分中找不到名为
build运行的作业。jobs:
我遇到了这些错误,但我对 yaml 真的很陌生,所以我无法真正找到它不起作用的原因。有任何想法吗?有人说它可能有额外的空格或其他东西,但我真的找不到它。
yaml 文件
defaults: &defaults:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
version: 2
jobs:
build:
docker:
- image: circleci/node:10.3.0
working_directory: ~/repo
steps:
<<: *defaults // << here
- run: npm run test
- run: npm run build
deploy:
docker:
- image: circleci/node:10.3.0
working_directory: ~/repo
steps:
<<: *defaults
- run:
name: Deploy …Run Code Online (Sandbox Code Playgroud) 我在以下基本工作流程中努力将SBT用于CI流程:
~/.sbt和~/.ivy2/cachetarget我项目中的所有目录在后续步骤中:
~/.sbt并~/.ivy2/cachetarget包含.class文件和相同源代码的目录(应该是相同的签出)sbt test100%的时间,sbt test重新编译整个项目。我想了解或调试为什么会这样,因为自上次编译以来没有任何变化(嗯,什么也没有变化,那么是什么导致它相信某些东西呢?)
我当前正在将circleci与docker executor一起使用。这意味着从同一张图片开始,有一个新的docker实例运行每个步骤,尽管我希望缓存可以解决这个问题。
的相关部分.circleci/config.yml(如果您不使用圆形,则应该仍然可以使用;我已注释了我可以的内容):
---
version: 2
jobs:
# compile and cache compilation
test-compile:
working_directory: /home/circleci/myteam/myproj
docker:
- image: myorg/myimage:sbt-1.2.8
steps:
# the directory to be persisted (cached/restored) to the next step
- attach_workspace:
at: /home/circleci/myteam
# git pull to /home/circleci/myteam/myproj
- checkout
- restore_cache:
# look for a …Run Code Online (Sandbox Code Playgroud) continuous-integration scala sbt circleci circleci-workflows
我正在尝试创建一个 Circleci 工作流程,该工作流程构建 java WAR 并将其上传到我的组织现有的 S3 工件存储桶存储库。首先,构建项目并将一些信息保存在文件中,并将 VERSION 放入 BASH_ENV 中:
export "VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $BASH_ENV
if [ $CIRCLE_BRANCH = "master" ]; then
ENVIRONMENT=production
elif [ $CIRCLE_BRANCH = "develop" ]; then
ENVIRONMENT=qa
elif [ $CIRCLE_BRANCH = "release-1.0" ]; then
ENVIRONMENT=staging
else
ENVIRONMENT=$CIRCLE_BRANCH
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> project.info
if [ -z "$ENVIRONMENT" ]; then
echo No environment is set
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
然后,我尝试使用官方 S3 orb 上传工件:
steps:
- attach_workspace:
at: .
- run: source project.info
- …Run Code Online (Sandbox Code Playgroud) CircleCI 有一个CIRCLE_BRANCH环境变量,它告诉您 PR 本身的分支名称。
但我想要相反,我需要 PR 试图合并的分支名称。
我目前正在尝试使用commandsCircleCI 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) 是否可以在另一个作业的上下文中运行另一个作业?我的一些工作有一些共同的步骤,我不想在不同的工作中重复这些步骤。
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) 我已遵循作业和条件工作流程中的条件步骤中描述的指南,并为我的 CircleCI 管道编写了以下代码。
version: 2.1
workflows:
version: 2.1
workflowone:
when:
condition: false
jobs:
- samplejob:
workflowtwo:
when:
condition: true
jobs:
- jobone
jobs:
samplejob:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 1
command: |
echo "This job is in workflowone and the workflow should not run"
jobone:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 2
command: |
echo "This job is in workflowtwo and the workflow should run"
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,输出不是预期的。第一个工作流不应运行,因为条件为假。当管道触发时,两个工作流程都开始运行。谁能指出这里缺少的部分吗?
我有一个简单的用例,我只想对特定的分支和/或标签进行手动批准。
与type:approval其他所有作业一样,具有的工作流作业具有过滤器,但需要(或不需要)人工批准的作业foo将使用requires: ['approve'],然后与之紧密链接。
这意味着如果批准步骤与过滤器不匹配,则foo根本不会发生。
所以..任何干净的解决方法,yaml文件中没有很多重复项?
我在 circle ci 上使用 Maven liquibase 插件运行数据库作业。我需要从 AWS Parameter store 读取用户名、密码、dburl 等参数。但是当我尝试将 aws cli 返回的值设置为自定义变量时,它始终为空白/空。我知道该值存在是因为 mac 终端上的相同命令返回一个值。
我正在使用 Bash 脚本通过 circle ci 作业安装 AWS CLI。当我在 .sh 文件中回显密码时,我看到了该值,但是当我在 config.yml 上回显时,我看到了空白的空值。我还尝试使用 aws ssm 和 config.yml 文件来获取值,但即使在那里该值也是空的。
我的配置文件
version: 2
references:
defaults: &defaults
working_directory: ~/tmp
environment:
PROJECT_NAME: DB Job
build-filters: &filters
filters:
tags:
only: /^v[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}-(dev)/
branches:
ignore: /.*/
jobs:
checkout-code:
<<: *defaults
docker:
- image: circleci/openjdk:8-jdk-node
steps:
- attach_workspace:
at: ~/tmp
- checkout
- restore_cache:
key: cache-{{ checksum "pom.xml" }}
- save_cache:
paths: …Run Code Online (Sandbox Code Playgroud) 我是 Circleci 的新手,我试图限制我的构建仅在特定分支上工作,我尝试了下面的配置文件,但是当我包含过滤器部分时,我收到以下错误:
Your config file has errors and may not run correctly:
2 schema violations found
required key [jobs] not found
required key [version] not found
Run Code Online (Sandbox Code Playgroud)
带过滤器的配置:
version: 2
jobs:
provisioning_spark_installation_script:
working_directory: ~/build_data
docker:
- image: circleci/python:3.6.6-stretch
steps:
- setup_remote_docker:
docker_layer_caching: true
- checkout
- run: &install_awscli
name: Install AWS CLI
command: |
sudo pip3 install --upgrade awscli
- run: &login_to_ecr
name: Login to ECR
command: aws ecr get-login --region us-east-1 | sed 's/-e none//g' | bash
workflows:
version: …Run Code Online (Sandbox Code Playgroud) 我试图使用 CircleCI 将我的主分支文件部署到 FTP 服务器(cpanel、apache)。我正在遵循本文中描述的说明。
但我在“node .circleci/deploy.js”上遇到错误
这是完整的错误日志:
#!/bin/bash -eo pipefail node .circleci/deploy.js internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module '/home/circleci/project/.circleci/deploy.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
at startExecution (internal/bootstrap/node.js:276:5)
at startup (internal/bootstrap/node.js:227:5)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) Exited with code 1
Run Code Online (Sandbox Code Playgroud)
这是“.circleci”文件夹中的config.yml和 config.js 文件。
version: 2
jobs:
build:
docker:
- image: circleci/node:latest
steps:
- checkout
- run: npm install
- run: node .circleci/deploy.js
- run: echo "WE'RE ONLINE"
workflows:
version: …Run Code Online (Sandbox Code Playgroud) circleci ×11
circleci-2.0 ×10
yaml ×2
aws-cli ×1
devops ×1
pipeline ×1
postgresql ×1
sbt ×1
scala ×1
shell ×1