Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow non-zero return codes in Travis CI .yml

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.

like image 455
SJC Avatar asked Feb 17 '16 09:02

SJC


People also ask

Which of the following type of commands are supported by Travis CLI?

There are three types of commands: Non-API Commands, General API Commands and Repository Commands. All commands take the form of travis COMMAND [ARGUMENTS] [OPTIONS] .

Which of the following are two main parts of Travis CI job?

The first job is to build the image and the second job is going to be to run the NPM test target.

What is Travis Yml and how is it used?

travis. yml is a configuration file, which provides instructions to the testing and building software on how to run tests and build any files required by the project. This file is part of the repository's git repository.


2 Answers

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.

like image 177
schnatterer Avatar answered Sep 20 '22 03:09

schnatterer


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]

like image 36
Maël Pedretti Avatar answered Sep 22 '22 03:09

Maël Pedretti