持续集成

1. Fastlane for iOS

安装

  • Requirements

    • Mac OS 10.9 or newer
    • Ruby 2.0 or newer (ruby -v)
    • Xcode
    • Xcode command line tools is installed

      $ xcode-select --install   //如果安装过了,会提示:already installed, use "Software Update" to install updates
      
  • install:

    sudo gem install fastlane --verbose
    
  • 设置

    fastlane init
    

Building

  • gym

    build and package iOS app, alternative is [ipa] command
    $gym -s "RongziTong" -q 'AdHoc'    //指定 scheme & configuration
    
  • ipa

    打包ADHOC版本要用ipa, 用gym会出问题,安装不到手机上。
    $sudo gem install shenzhen
    $ipa build     // 打包APP
    $ipa distribute:pgyer -f RongziTong.ipa -a 29e9bbe3779e52eba93232e59bfea1ea -u 7409a6fe57688aeaec668a9f450d6ea8  // 蒲公英
    $ipa distribute:ftp  //FTP服务
    
  • xcodebuild

Testing

  • xctest
  • scan

    scan(
      workspace: "RongziTong.xcworkspace",
      scheme: "RongziTong",
      clean: false,
      output_directory: "build"
    )
    

Deploying

  • pilot

    $pilot list        // list all tester in itunes connect
    $pilot builds  // list all builds in itunes connect
    $pilot upload    // 上传ipa, Successfully uploaded package to iTunes Connect. It might take a few minutes until it's visible online
    $pilot upload --skip_submission  // only be uploaded and not distributed to testers
    
  • deliver

    deliver(force: true)
    $ deliver init         //  从app store 下载项目相关配置, screen shots
    $ deliver download_screenshots
    $ sudo gem update deliver   // 升级deliver
    
  • supply

  • 蒲公英

Modifying Project

  • increment_build_number
  • increment_version_number
  • get_build_number(xcodeproj: “RongGuanJia.xcodeproj”)
  • badge: badge(alpha: true)

    badge(alpha: true)
    $ brew install graphicsmagick        //  http://stackoverflow.com/questions/29377651/rails-error-imagemagick-graphicsmagick-is-not-installed
    $ git checkout RongziTong/Images.xcassets/     // reset the badge back 
    
  • update_info_plist: 修改APP Name

Using git

ensure_git_status_clean         # make sure, no uncommited changes are deployed by `fastlane
ensure_git_branch               # defaults to `master` branch
git_pull                    # Executes a simple git pull --tags command
commit_version_bump(            # create a "Version Bump" commit in your repo
            message: 'fastlane adhoc version ' + target_version, # create a commit with a custom message
        )
push_to_git_remote              # pushes 'master' branch to 'origin' remote
add_git_tag(
            tag: 'my_custom_tag'
        )
push_git_tags

ISSUE

2. Gradle for Android

website
book
download

安装 gradle

$ brew install gradle  
$ gradle -v
$ gradle tasks
$ gradle init
$ gradle build   ==    $ ./gradlew build   // 执行 check 和 assemble 两个任务
$ gradle clean
$ gradle assemble

build.gradle文件

  • 为什么有MavenCentral: download maven:用于下载第三方Library
  • Gradle version 1.10 is required, current version is 2.12:
    修改为:classpath ‘com.android.tools.build:gradle:2.0.+’

  • SDK Build Tools revision (19.0.0) is too low, Minimum requirement is 19.1.0:
    $ android sdk 升级sdk build tool 版本

  • could not found AndroidManifest.xml File:
    需要配置目录,修改默认目录src/main 为 src sourceSets in android

  • 点9图片,图片命名错误等问题

  • No resource found that matches the given name (at ‘icon’ with value ‘@drawable/ic_launcher’). :需要配置:res.srcDirs ‘res’

  • 非法字符问题

  • 终止Lint检查: lintOptions{ abortOnError false}

  • 签名Release: signingConfig signingConfigs.release

  • productFlavors:

    //渠道Flavors,我这里写了一些常用的,你们自己改
    productFlavors {
         store360{}
         baidu{}
         dongfangrongziwang{}
         xiaomi{}
     }
    
  • 多渠道打包

    //替换AndroidManifest.xml的UMENG_CHANNEL_VALUE字符串为渠道名称
    android.applicationVariants.all{ variant ->
         variant.outputs.each { output ->
             output.processManifest.doLast {
                 //v1.11之前这里用的copy{},我换成了文件操作,这样可以在v1.11版本正常运行,并保持文件夹整洁
                 //${buildDir}是指build文件夹
                 //${variant.dirName}是flavor/buildtype,例如GooglePlay/release,运行时会自动生成
                 //下面的路径是类似这样:build/intermediates/manifests/GooglePlay/release/AndroidManifest.xml
                 def manifestFile = "${buildDir}/intermediates/manifests/full/${variant.dirName}/AndroidManifest.xml"
                 //将字符串REPLACE_KEY替换成flavor的名字
                 def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll("dongfangrongziwang", "${variant.productFlavors[0].name}")
                 new File(manifestFile).write(updatedContent, 'UTF-8')
                 //将此次flavor的AndroidManifest.xml文件指定为我们修改过的这个文件
                 output.processResources.manifestFile = file("${buildDir}/intermediates/manifests/full/${variant.dirName}/AndroidManifest.xml")
             }
         }
     }
    

ISSUE

Jenkins

Tomcat

[offical]](http://tomcat.apache.org/)
安装

将Tomcat copy到 ~/Library目录
$ chmod 755 bin/*.sh  //不要加sudo 否则会变成root用户
$ ./bin/startup.sh
$ ./bin/shutdown.sh

安装包分发平台

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐