Could not parse .travis.yml
Asked Answered
P

3

6

I'm trying to create CI pipeline with GitHub, Travis CI and AWS ECS. When I'm push commit to master branch, I'm getting error in travis CI: 'Could not parse .travis.yml'. I can't figure out, where is the problem. Travis dosen't provide more information about error.

There is a code, which I'm using:

.travis.yml

language: csharp
dist: trusty
sudo: required
mono: none
dotnet: 2.0.0
branches:
    only:
        - master
before_script:
    - chmod -R a+x scripts
script:
    - ./scripts/dotnet-build.sh
    - ./scripts/dotnet-publish.sh
    - ./scripts/docker-publish-travis.sh

dotnet-build.sh

 dotnet restore 
 dotnet build

dotnet-publish.sh

dotnet publish ./BookMeMobi2 -c Release -o ./bin/Docker

dotnet-publish-travis.sh

pip install --user awscli
eval $(aws ecr get-login --no-include-email --region eu-central-1)
docker build -t bookmemobi2 .
docker ps
docker tag bookmemobi2:latest 601510060817.dkr.ecr.eu-central-1.amazonaws.com/bookmemobi2:latest
docker push 601510060817.dkr.ecr.eu-central-1.amazonaws.com/bookmemobi2:latest

I don't know where is the problem. Could you help me?

Premier answered 27/5, 2018 at 10:36 Comment(1)
I used to use 4 space tabulation. In yaml file we should use 2 space tabulation. Also, there was a problem with windows end of lines (use UNIX eof).Aletheaalethia
F
10

Use yamllint, which you can install, or just copy&paste to a web-based version.

With the example in the question, I get:

(<unknown>): found character that cannot start any token while scanning for the next token at line 7 column 1

There's a tab on line 7. See "https://mcmap.net/q/272675/-a-yaml-file-cannot-contain-tabs-as-indentation".

Falsework answered 21/2, 2019 at 21:3 Comment(0)
S
0

I had a similar problem. In my case I was using python to launch a couple of scripts. I placed them one after the other with a hyphen at the beginning, exactly as you. So I searched to found out that I could place all of them in one line with "&" between each script and I got rid of the hyphen.

What I had:

 script: 
 - python  test_Math_DC.py
 - python test_Math_Moy.py
 - python test_Math_Var.py
 - python test_Math_SQRT.py

Changed to :

script: python test_Math_DC.py & python test_Math_Moy.py & python test_Math_Var.py & python test_Math_SQRT.py

In your case you could try :

script: ./scripts/dotnet-build.sh & ./scripts/dotnet-publish.sh & ./scripts/docker-publish-travis.sh

or something like this :

script: sh ./scripts/dotnet-build.sh & sh ./scripts/dotnet-publish.sh & sh ./scripts/docker-publish-travis.sh

And see how it works out.

Selectivity answered 22/6, 2018 at 2:55 Comment(1)
In my case, that was a problem with tabulation. I had setup vs code with 4 space tabulation. .Yaml file expect 2 space tabulation.Aletheaalethia
P
0

The travis cli tool has a linter

gem install travis

However, it only gives warnings for the example. Also, it currently does not work with all features, for example stages.

$ travis lint
Warnings for .travis.yml:
[x] unexpected key mono, dropping
[x] unexpected key dotnet, dropping
Platter answered 15/6, 2019 at 13:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.