Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent failure when yaml parsing error #672

Closed
floatdrop opened this issue Nov 6, 2014 · 10 comments
Closed

Silent failure when yaml parsing error #672

floatdrop opened this issue Nov 6, 2014 · 10 comments

Comments

@floatdrop
Copy link

If .drone.yml is malformed misguiding error will be printer.

@bradrydzewski
Copy link

Can you verify that we correctly logged an error message?
https://github.com/drone/drone/blob/master/server/worker/docker/docker.go#L86

If yes, we can just alter that line of code to update the commit as failed and then to exit.

@floatdrop
Copy link
Author

@bradrydzewski yes, this what I got in log file:

2014/11/06 16:42:38 Error parsing YAML for project-stub/generator-project-stub, Err: YAML error: line 10: did not find expected alphabetic or numeric character

To be more specific, line in script caused this:

script:
  - [ $CI_BRANCH -eq "master" ] && npm run release

@bradrydzewski
Copy link

OK great, just wanted to make sure that line triggered an error message. Instead of logging to the console we can write the error to the build output, mark the build as StatusError and exit before actually running the build.

@kylewelsby
Copy link

You could do something like this.

create a file ./bin/ci-deploy.sh/ and chmod +x ./bin/ci-deploy.sh

#!/bin/bash -i
if [ "$DRONE_BRANCH" ]
then
    if [ $DRONE_BRANCH = "master" ]
    then
        bundle install --path vendor/bundle
        bundle exec cap production deploy
    fi
fi

then in your .drone.yml

deploy:
    bash:
        script:
           - ./bin/ci-deploy.sh

@cboettig
Copy link

cboettig commented Jan 4, 2015

Thanks for the quick reply and the complete example, that worked perfectly for me. Of course it would be cleaner if drone didn't trigger other branches but I appreaciate the workaround. (Didn't realize $DRONE_BRANCH was already defined by default either, that's also handy to know).

Thanks again for this really excellent project.

@bradrydzewski
Copy link

another example that might help specifically with deployment and publishing is the when clause:

image: gcc
script:
  - make
  - make test

deploy:
  bash:
    script:
      - make deploy
    when:
      branch: master

The above approach works well if you want to limit deployments to a single branch (ie master). The approach, however, falls short if you want to run a different deployment script for each branch (ie master, staging). In this case you'll definitely want to use the approach suggested by @kylewelsby until we get #696 resolved.

@bradrydzewski bradrydzewski modified the milestone: Unplanned Aug 18, 2015
@bradrydzewski bradrydzewski changed the title Error: missing Docker image on invalid yaml Silent failure when yaml parsing error Oct 26, 2015
@bradrydzewski bradrydzewski modified the milestones: v0.4.1, Unplanned Nov 6, 2015
@bradrydzewski bradrydzewski modified the milestones: v0.4.1, Unplanned Jul 13, 2016
@lae
Copy link

lae commented Feb 13, 2017

I just hit this today actually, but the error was not printed in the server log and I only saw it while sniffing network traffic:
Failed to parse yaml file or calculate matrix. yaml: line 4: mapping values are not allowed in this context
when a developer I work with accidentally added typoed image into a dict, like so:

pipeline:
  build:
    image: python: 3.5.1-alpine

(and for additional context this repo had no builds yet, so whatever solution is used, it should be able to handle that scenario too)

@bradrydzewski bradrydzewski added this to Development in Version 0.6 Mar 15, 2017
@bradrydzewski bradrydzewski moved this from Development to Released in Version 0.6 Mar 16, 2017
@bradrydzewski
Copy link

fixed in 0.6

@floatdrop
Copy link
Author

@bradrydzewski did you mean 0.5?

@bradrydzewski
Copy link

I introduced an 0.6 tag since I needed to make a breaking change to the agent <> server communication, and didn't want to impact existing 0.5 installs. I will post to the discourse forum and gitter once it is safe to upgrade to 0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Version 0.6
Released
Development

No branches or pull requests

5 participants