Unable to build 'yml' file what could be the fault - heroku

Can someone help me indent this .yml file? Each time I set it I get an error:
Unable to parse YAMLmapping values are not allowed here in 'string', line 1, column 17: version: 2.1orbs: heroku: circleci/heroku#0.0.1 ... ^
version: 2.1
orbs:
heroku:
circleci/heroku#0.0.10
workflows:
heroku_deploy:
jobs: - heroku/deploy-via-git
thank you

Could be that the element in jobs has to be on a new line and indented?
version: 2.1
orbs:
heroku:
circleci/heroku#0.0.10
workflows:
heroku_deploy:
jobs:
- heroku/deploy-via-git

I believe your line endings aren't being recognized properly. Line 1, column 17 corresponds to the end of this single line, which you believe to be two lines:
version: 2.1orbs:
Make sure your file is encoded as UTF-8 and uses Unix line endings, then try again.

Related

YAML mapping values are not allowed here - possible indentation issue?

So I am trying to learn CircleCI and been following the getting started tutorial: https://circleci.com/docs/2.0/getting-started/
config.yml:
version: 2
jobs:
one:
docker:
- image: circleci/ruby:2.4.1
steps:
- checkout
- run: echo "A first hello"
- run: sleep 25
two:
docker:
- image: circleci/ruby:2.4.1
steps:
- checkout
- run: echo "A more familiar hi"
- run: sleep 15
workflows:
version: 2
one_and_two:
jobs:
- one
- two
This returns
Error: Unable to parse YAML
mapping values are not allowed here
in 'string', line 2, column 6:
jobs:
^
I don't understand the problem. From the documentation, it appears that it is the correct indentation level. So what is the source of this error, exactly?
The documentation shows clearly that version and jobs must be on the same indentation level. If you indent jobs more, you make it part of the scalar 2.
This would be valid YAML:
version: 2
jobs
and equalivalent to:
version: 2 jobs
However, the : after jobs makes it invalid since YAML does not allow implicit keys to be multi-line (version: would be a proper implicit key).
To fix the error, simply do not indent jobs more than version.

CircleCI version 2.1 - "Cannot find a definition for command named 'restore-cache'"

I'm currently attempting to use the commands feature available in CircleCI version 2.1, so that I can reuse some common commands. I'm testing using the CLI command:
circleci config process ./.circleci/config.latest.yaml > ./.circleci/config.yml
But I recieve the following error:
Error: Error calling workflow: 'main'
Error calling job: 'build'
Error calling command: 'build_source'
Cannot find a definition for command named restore-cache
It seems that restore-cache works just fine in a straight-up version 2 config file, but when I try and process a 2.1 file using process it kicks up a fuss.
Below is an edited version of my config.yaml file which should hopefully be of some use. Please let me know if there is any additional information that would be useful.
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 src, builds documentation, and runs tests'
steps:
- restore-cache: *restore-root-cache
- other-commands...
jobs:
build:
<<: *defaults
steps:
- checkout
- build_source
workflows:
version: 2.1
main:
jobs:
- build:
filters:
branches:
ignore: develop
The command is restore_cache (with an underscore), not restore-cache (with a dash) https://circleci.com/docs/2.0/configuration-reference/#restore_cache
It should work in commands.
restore cache is a special step that needs to be under a job. Not another command.

CircleCI API behaving differently from github commit trigger?

I'm running the cypress-example-kitchen sink app on CircleCI.
This is my yaml config script:
version: 2.1
orbs:
cypress: cypress-io/cypress#1.0.1
workflows:
build:
jobs:
- cypress/install:
build: 'npm run build'
- cypress/run:
requires:
- cypress/install
start: 'npm start'
This kicks off and passes just fine when I make a commit to my fork of the repo above.
However, when I try to execute a CircleCI build programmatically, using
curl -X POST https://circleci.com/api/v1.1/project/github/Atticus29/cypress-example-kitchensink?circle-token=myApiToken, the build fails and the jobs dashboard on CircleCI tells me that something is wrong with my config file:
6 schema violations found required key [jobs] not found workflows:
5 schema violations found
workflows: minimum size: [2], found: 1
workflows: build: jobs: 4 schema violations found
workflows: build: jobs: 0: 0 subschemas matched instead of one
workflows: build: jobs: 0: expected type: String, found: Mapping
workflows: build: jobs: 0: install: extraneous key [build] is not permitted
workflows: build: jobs: 1: 0 subschemas matched instead of one
workflows: build: jobs: 1: expected type: String, found: Mapping
workflows: build: jobs: 1: run: extraneous key [start] is not permitted
And that something went wrong with my build:
Build-agent version 0.1.1216-48f80d08 (2018-12-07T16:01:40+0000)
Configuration errors: 2 errors occurred:
Configuration version 2.1 requires the "Enable Build Processing" project setting. Enable Build Processing under Project Settings ->
Advanced Settings. In order to retrigger build processing, you must
push a new commit.
Cannot find a job named build to run in the jobs: section of your configuration file. If you expected a workflow to run, check your
config contains a top-level key called 'workflows:'
I can confirm that Enable Build Processing is on.
None of these were problems when I ran the build in the usual way. Any advice?
Circle CI for some reason keeps on assuming that the projects are not set up for v2.0 despite config.yml being called the right thing and living in the right place in the repo. After a few commits, this issue seems to go away?
I ended up running a build programmatically with the following script:
#!/bin/bash
PERSONAL_TOKEN=myPersonalTokenHere
MOST_RECENT_BUILD=`curl -s "https://circleci.com/api/v1.1/recent-builds?circle-token=$PERSONAL_TOKEN&limit=1"| grep 'build_num'|grep -o '\d.'|sed 's/,//g'|sort -r -n|head -n1`
curl -X POST "https://circleci.com/api/v1.1/project/github/holmbergius/wildMeCypress/$MOST_RECENT_BUILD/retry?circle-token=$PERSONAL_TOKEN"

Syntax error in processing yaml

I have the following yml:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns: 40
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"
I get a syntax error though, on the standalonedb_host line. What am I doing wrong?
edit: Oddly enough, if I de-indent the standalonedb vars, the errors go away. If I add spaces again, the error returns.
The issue is that you have a key/value pair nested under a key/value pair ie standalonedb_host: myhost0001.ab-xy.aws.com (and the rest of the standalonedb_* config) is nested under maxconns: 40.
Depending on your configuration, either of the following should fix the issue:
Remove the nesting:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns: 40
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"
Remove the value in maxconns so the standalonedb_*-related hash becomes the value of the maxconns key:
mongo:
version: 2.6.9
repo: http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/
maxconns:
standalonedb_host: myhost0001.ab-xy.aws.com
standalonedb_port: 8399
standalonedb: "{{standalonedb_host}}:{{standalonedb_port}}"

Doctrine 2 cli - Command Line Tool - Unexpected character in input - Generate entities

I am having a problem with running commands via cli doctrine-cli.php file. I am using Doctrine 2 and Codeigniter 2. I would like to generate entities via Command Line Tool, but without success. Page is hosted by Hostgator. On this server is installed by default PHP version 5.2, but you can use PHP version 5.3 by adding some commands to .htaccess file located in root.
In the Command Line Tool I get this error:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/tig3rb0y/public_html/naselsi/application/doctrine-cli.php on line 10
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/tig3rb0y/public_html/naselsi/application/doctrine-cli.php on line 10
Parse error: syntax error, unexpected T_STRING in /home/tig3rb0y/public_html/naselsi/application/doctrine-cli.php on line 10
If I run a file with PHP version via url, I get PHP version 5.3, but if I run the same file via Command Line Tool, I get php version 5.2. Why is that so?
Is there any solution for that?
Regards, Mario
I have a solution. As already #KeesSchepers said, there was a problem that in command line there was default 5.2.17 PHP version. I solved that simply, I just added prefix /opt/php53/bin/php to all doctrine2 commands, example:
/opt/php53/bin/php doctrine-cli.php orm:...
Thank you guys!

Resources