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

Hugo should exit with an error code in case of errors when building a website #740

Closed
anthonyfok opened this issue Dec 26, 2014 · 14 comments

Comments

@anthonyfok
Copy link
Member

To help notify the user of problems when Hugo is run as an automated script on the web server, I think Hugo should exit with an error code if there are warnings/errors when building a website.

For example, due to a bug either in Hugo docs or in the source code, some error messages are displayed during a hugo run:

$ cd ~/git/hugo/docs
$ hugo
ERROR: 2014/12/26 Two or more menu items have the same name/identifier in "<map[interface {}]interface {} Value>" Menu. Identified as "Overview".
 Rename or set a unique identifier. 
ERROR: 2014/12/26 Two or more menu items have the same name/identifier in "<map[interface {}]interface {} Value>" Menu. Identified as "Ordering".
 Rename or set a unique identifier. 
0 draft content 
0 future content 
87 pages created 
15 tags created
0 groups created
in 214 ms
$ echo $?
0

The fact that the above returns an error code of 0 means that most automatic deployment scripts (except the really smart ones who grep strings like ERROR and WARNING in the hugo output) would fail to detect any errors, leaving potential build problems undetected.

@bep
Copy link
Member

bep commented Dec 26, 2014

Agree, but a note on the above error. This is related to the discussion near the end here:

#722

@anthonyfok
Copy link
Member Author

Good to know where this bug comes from. Thanks for letting me know!

@anthonyfok anthonyfok changed the title Hugo should exit with an error code in case of errors when buildling a website Hugo should exit with an error code in case of errors when building a website Jan 20, 2015
@flowchartsman
Copy link

It seems like there are two solutions to this problem:

  1. Audit the code, identifying all notable errors and setting a flag
  2. Patch jww to (optionally?) track whether or not an ERROR, CRITICAL or FATAL has been emitted and then use that to determine exit code.

Number 2 is certainly the easiest solution, but it would necessitate an issue there. Thoughts?

@batmat
Copy link
Contributor

batmat commented Oct 6, 2015

+1. Critical IMO: finding potential 404 and so on ahead of deployment is certainly one pros of SSG. It would be great to have that.
Just found this issue after noticing I had used an incorrect relref but Hugo would not fail to deploy the site (automated, in my case, as @anthonyfok rightly points out as an example), hence not alerting me.
Thanks and congrats again for Hugo!

@bep
Copy link
Member

bep commented Dec 2, 2015

I think this situation should be better after:

#1502

@phil-opp
Copy link
Contributor

Is there any update on this? I want to update my page automatically via travis on every commit. But travis looks only at the exit status, so it happily deploys it even if many errors occured.

@bep
Copy link
Member

bep commented Feb 17, 2016

@phil-opp see my last comment. What errors do you see that doesn't exit != 0 ?

@phil-opp
Copy link
Contributor

Links to non-existing pages:

Started building site
ERROR: 2016/02/17 22:52:43 template_funcs.go:1167: No page found with path or logical name "does-not-exist.md".
0 draft content
0 future content
10 pages created
0 non-page files copied
0 paginator pages created
0 tags created
0 categories created
in 10348 ms

@bep bep self-assigned this Feb 18, 2016
bep added a commit to bep/jWalterWeatherman that referenced this issue Feb 18, 2016
The use case in Hugo is to exit with an error code
when *any* ERROR logging has occured.

See gohugoio/hugo#740
@bep
Copy link
Member

bep commented Feb 18, 2016

This should help fix this:

spf13/jwalterweatherman#10

/cc @spf13

bep added a commit to bep/jWalterWeatherman that referenced this issue Feb 18, 2016
The use case in Hugo is to exit with an error code
when *any* ERROR logging has occured.

See gohugoio/hugo#740
bep added a commit to bep/jWalterWeatherman that referenced this issue Feb 23, 2016
The use case in Hugo is to exit with an error code
when *any* ERROR logging has occured.

See gohugoio/hugo#740
@bep
Copy link
Member

bep commented Feb 24, 2016

The maintainer of the log library we use seems to have abandoned it, so I have given up on that approach. I may revisit this later.

@bep bep removed their assignment Feb 24, 2016
@phil-opp
Copy link
Contributor

Isn't it owned by the same owner as hugo?

@bep
Copy link
Member

bep commented Feb 27, 2016

Isn't it owned by the same owner as hugo?

Yes ... or: The Hugo contributors owns Hugo.

bep added a commit to spf13/jwalterweatherman that referenced this issue Mar 11, 2016
The use case in Hugo is to exit with an error code
when *any* ERROR logging has occured.

See gohugoio/hugo#740
@bep bep closed this as completed in 7cd69aa Mar 11, 2016
@phil-opp
Copy link
Contributor

Thanks a lot!

tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
@github-actions
Copy link

github-actions bot commented Apr 8, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants