问题
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 bygrep
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 ignoregrep
s 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