How to access output files in Travis?

2020-06-13 03:07发布

问题:

I'm trying to deploy an Android library on Bintray using Travis-CI. But when I upload my repo... I got this:

Ran lint on variant release: 6 issues found

Ran lint on variant debug: 6 issues found

Wrote HTML report to file:///home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html

Wrote XML report to file:///home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.xml

:app:lint FAILED

Normally I would go to my project out put and read the lint-results-debug.html... But I don't know how to access this file in Travis.

So, How can I access outputs/lint-results-debug.html in Travis??

Any help is welcome!

Edit

my .travis.yml:

language: android
jdk: oraclejdk8
sudo: false

addons:
  apt:
    packages:
      - lynx

android:
  components:
  - platform-tools
  - tools
  - build-tools-25.0.0
  - android-25
  - extra-android-m2repository
script: 
  - if [ -f /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html ]; then lynx -dump /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html; fi
  - ./gradlew -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build
  bintrayUpload --stacktrace --info
env:
  global:
  - secure: [...]
  - secure: [...]

回答1:

You can use lynx -dump to dump a plain-text rendering of outputs/lint-results-debug.html.

To make Travis install lynx -dump: To the top of your .travis.yml, add this:

addons:
  apt:
    packages:
      - lynx

To make Travis show the lint output using lynx: In the script part of your .travis.yml, add:

after_failure:
  - if [ -f /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html ]; then lynx -dump /home/travis/build/leandroBorgesFerreira/MoreCLoseButton/app/build/outputs/lint-results-debug.html; fi


回答2:

While sideshowbarker gave a generic answer, I'd like to point out that Android lint has an option for console output, so you can do this in your build.gradle:

android {
    lintOptions {
        textReport = true
        //textOutput "stdout" // default location, perfect for travis
    }
}

Which removes the need for an extra dependency, and an extra script; plus it's reproducible on local machine easily.

One can take this a step further (in case spamming console on local machine is to be avoided) and do

android {
    lintOptions {
        textReport = project.property("lint.output.console").toBoolean()
    }
}

and in gradle.properties: lint.output.console=false

and in .travis.yml: gradlew -Plint.output.console=true build