Allow non-zero return codes in Travis CI .yml

放肆的年华 提交于 2021-01-18 10:12:25

问题


I am trying to setup Travis CI to build a latex report. When building the latex report some steps have to be repeated and so the first time they are called there is a non-zero return code.

My travis.yml so far is

language: R

before_install:
  - tlmgr install index

script:
    - latex report
    - bibtex report
    - latex report
    - latex report
    - dvipdf report.dvi report.pdf

However in Travis Docs it states

If script returns a non-zero exit code, the build is failed, but continues to run before being marked as failed.

So if my first latex report command has a non zero return code it will fail the build.

I would only like the build to fail if the last latex report or dvipdf report failed.

Does anyone have any idea or help?

Thanks in advance.


回答1:


Just append || true to your command.

(complex) Example:

- (docker run --rm -v $(pwd)/example:/workdir stocker-alert || true) 2>&1 | tee >(cat) | grep 'Price change within 1 day'
  • The docker command returns < 0 (because it's a negative test), but we want to continue anyway
  • 2>&1 - stderr is forwarded to stdin (to be picked up by grep later)
  • tee - the output is printed (for debugging) and forwarded to grep
  • Finally grep asserts if the output contains a required string. If not, grep returns > 0 failing the build.
    If we wanted to ignore greps result we would need another ||true after grep.

Taken from schnatterer/stock-alert.




回答2:


Not directly related with your original question but I had quite the same problem.

I found a solution using latexmk. This runs latex and bibtex as many times as needed.

If you look at my Travis configuration file :

https://github.com/73VW/TechnicalReport/blob/master/.travis.yml

You will see that you simply have to add it in apt dependencies.

Then you can run it like this: latexmk -pdf -xelatex [Your_latex_file]



来源:https://stackoverflow.com/questions/35452147/allow-non-zero-return-codes-in-travis-ci-yml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!