美文网首页
Android Gitlab CI/CD脚本

Android Gitlab CI/CD脚本

作者: zero_li | 来源:发表于2018-09-05 18:09 被阅读0次
    # This file is a template, and might need editing before it works on your project.
    # Read more about this script on this blog post https://about.gitlab.com/2016/11/30/setting-up-gitlab-ci-for-android-projects/, by Greyson Parrelli
    image: openjdk:8-jdk
    
    variables:
      SOURCE_FILE_PATH: "./app/build/outputs/apk/*"
      # 修改存放路径
      TARGET_FILE_PATH: "/home/android-apk/ProjectName/app/"
    
    before_script:
      - export ANDROID_HOME=/opt/android_sdk/
      - export PATH=$PATH:/opt/android_sdk/platform-tools/
      - chmod +x ./gradlew
    
    # 理解为阶段,阶段的执行顺序
    stages:
      - build
      - assemble
      - deploy
    
    # push master 执行任务
    job_build:
      stage: build
      # 所需执行的脚本
      script:
        - ./gradlew clean
        - ./gradlew assembleRelease
      only:
        - master
    
    #================================================================
    # 打git tag 分支名称 ,正则匹配 “V” 开头,符合则执行,如V1.0.0
    job_assemble:
      stage: assemble
      # 所需执行的脚本
      script:
        - ./gradlew clean
        - ./gradlew app:assembleRelease
        - 'mkdir -p ${TARGET_FILE_PATH}/assemble/'
        - 'cp -fRap ${SOURCE_FILE_PATH} ${TARGET_FILE_PATH}/assemble/'
      artifacts:
          paths:
            - ./app/build/outputs/
      only:
        - /^V.*$/
      except:
          - branches
    
    
    Build Job - job_build 
    =================================
    Tag list: 
    Only policy: refs, master 
    Except policy: 
    Environment: 
    When: on_success
    
    Assemble Job - job_assemble
    =================================
    Tag list: 
    Only policy: refs, /^V.*$/ 
    Except policy: refs, branches 
    Environment: 
    When: on_success
    
    

    相关文章

      网友评论

          本文标题:Android Gitlab CI/CD脚本

          本文链接:https://www.haomeiwen.com/subject/dfczwftx.html