how-to-use-travis-ci

如何简单入门持续集成( Travis-CI ) http://travis-ci.org/

APACHE-2.0 License

Stars
435

Travis-CI

Build failing 13 233333

Travis-CI

Travis-CI Travis-CI GitHub Commit Push

Travis-CI http://travis-ci.org/ GitHub http://travis-ci.com/

https://docs.travis-ci.com/ tarvis-ci

Travis-CI

1 GitHub Travis-CI GitHub

2Travis-CI GitHub Travis-CI

3 .travis.yml Travis-CI .travis.yml

Android

language: android
android:
  components:
    # Uncomment the lines below if you want to
    # use the latest revision of Android SDK Tools
    # - platform-tools
    # - tools

    # The BuildTools version used by your project
    - build-tools-19.1.0

    # The SDK version used to compile your project
    - android-19

    # Additional components
    - extra-google-google_play_services
    - extra-google-m2repository
    - extra-android-m2repository
    - addon-google_apis-google-19

    # Specify at least one system image,
    # if you need to run emulator(s) during your tests
    - sys-img-armeabi-v7a-android-19
    - sys-img-x86-android-17

4 .travis.yml push GitHub Travis-CI

5

language: android   # 

notifications:      #  false 
  email: false

sudo: false         # sudo 

android:            # 
  components:
    - tools
    - build-tools-23.0.2              
    - android-23                     
    - extra-android-m2repository     # Android Support Repository
    - extra-android-support          # Support Library

before_install:     
 - chmod +x gradlew  #  gradlew 

script:              # :
  - ./gradlew assembleRelease  

before_deploy:       # 
  #  mv  apk 
  - mv app/build/outputs/apk/app-release.apk app/build/outputs/apk/buff.apk  
 
deploy:              # 
  provider: releases #  GitHub ReleaseTravis CI  fir.imAWSGoogle App Engine 
  api_key:           #  GitHub  token Settings -> Personal access tokens -> Generate new token
    secure: 7f4dc45a19f742dce39cbe4d1e5852xxxxxxxxx 
  file: app/build/outputs/apk/buff.apk   # 
  skip_cleanup: true     #  true , apk 
  on:     #            
    tags: true       # tags  true  tag 

branches: , install: Customizing Your Build

GitHub Release

Travis CI 2 *

  • Travis CI System.getenv()

:

release {
    try {
        storeFile file("nukc.jks")
        storePassword KEYSTORE_PASSWORD
        keyAlias "C"
        keyPassword KEY_PASSWORD
    } catch (ex) {
        throw new Exception("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
    }
}

KEYSTORE_PASSWORD KEY_PASSWORD gradle.properties build.gradle gradle.properties .gitignore ,

release {
    try {
        storeFile file("nukc.jks")
        storePassword project.hasProperty("KEYSTORE_PASSWORD") ? KEYSTORE_PASSWORD : System.getenv("KEYSTORE_PASSWORD")
        keyAlias "C"
        keyPassword project.hasProperty("KEY_PASSWORD") ? KEY_PASSWORD : System.getenv("KEY_PASSWORD")
    } catch (ex) {
        throw new Exception("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
    }
}

Travis CI ruby CLI gem

gem install travis
travis encrypt-file nukc.jks --add

travis travis login --org Github travis login --pro

travis encrypt-file

  1. Travis CI : encrypted_e6c55137b621_key encrypted_e6c55137b621_iv
  2. openssl xx.jks.enc
  3. .travis.yml Travis CI .travis.yml
before_install:
    - gem install fir-cli
    - openssl aes-256-cbc -K $encrypted_e6c55137b621_key -iv $encrypted_e6c55137b621_iv
      -in nukc.jks.enc -out nukc.jks -d

.gitignore xx.jks gradle.properties

Bintray

Bintray apikey JCenter bintray.apikey bintray.user local.properties local.properties Travis CI build failing

local.properties

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"
        name = "Buff"    
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["MIT"]
        publish = true
    }
}

2 Travis CI

Properties properties = new Properties()
boolean isHasFile = false
if (project.rootProject.findProject('local.properties') != null){
    isHasFile = true
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
bintray {
    user = isHasFile ? properties.getProperty("bintray.user") : System.getenv("bintray.user")
    key = isHasFile ? properties.getProperty("bintray.apikey") : System.getenv("bintray.apikey")
    configurations = ['archives']
    pkg {
        repo = "maven"
        name = "Buff"    
        websiteUrl = siteUrl
        vcsUrl = gitUrl
        licenses = ["MIT"]
        publish = true
    }
}

Status Image

commit travis ci commit message [ci skip]

git commit -m "[ci skip] commit message"

travis-ci/issues Google / StackOverflow


/home/travis/build.sh: line 45: ./gradlew: Permission denied

gradlew gradlew .travis.yml

before_install:
 - chmod +x gradlew

failed to find Build Tools revision 23.0.2

- tools

android:
  components:
    - tools

failed to deploy

token


A problem occurred evaluating project ':app'. java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

.travis.yml

jdk:
  - oraclejdk8

  • What went wrong:
    A problem occurred evaluating project ':app'.

    Failed to apply plugin [id 'com.android.application'] Could not create plugin of type 'AppPlugin'.

gradle

build passing