简体   繁体   English

如何使用 gitlab 获取发布 apk? 光盘

[英]How to get release apk using gitlab? CI CD

NB: I new in gitlab CI CD注意:我在 gitlab CI CD 中新增

Found errors in your.gitlab-ci.yml:在 your.gitlab-ci.yml 中发现错误:

assembleRelease job: stage parameter should be .pre
build
test
deploy
.post

You can also test your.gitlab-ci.yml in CI Lint你也可以在 CI Lint 中测试 your.gitlab-ci.yml


My.gitlab-ci.yml code我的.gitlab-ci.yml 代码

image: openjdk:8-jdk

variables:   ANDROID_COMPILE_SDK: "29"   ANDROID_BUILD_TOOLS: "29.0.2" ANDROID_SDK_TOOLS: "4333796"

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
  - chmod +x ./gradlew   # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
  - set -o pipefail

lintDebug:   stage: build   script:
    - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug:   stage: build   script:
    - ./gradlew assembleDebug   artifacts:
    paths:
      - app/build/outputs/

debugTests:   stage: test   script:
    - ./gradlew -Pci --console=plain :app:testDebug

assembleRelease:
    stage: release   script:
  - echo $KEYSTORE_FILE | base64 -d > my.keystore
  - ./gradlew assembleRelease
    -Pandroid.injected.signing.store.file=$(pwd)/my.keystore
    -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
    -Pandroid.injected.signing.key.alias=$KEY_ALIAS
    -Pandroid.injected.signing.key.password=$KEY_PASSWORD   artifacts:
    paths:
    - app/build/outputs/apk/release
    - CHANGELOG



NB: Please share pipeline build test and release cd code for android注意:请分享 android 的管道构建测试和发布 cd 代码

Maybe I'm too late, but our.gitlab-ci.yml format is wrong.也许我来得太晚了,但是我们的.gitlab-ci.yml 格式是错误的。 You missed several new lines.您错过了几条新线路。 For example, in assembleRelease after the stage: release you need a new line, script: should be on a new line例如在assembleRelease stage: release需要换行, script:应该换行

  1. the ident in.yaml file is important. yaml 文件中的标识很重要。 You have mixed 2 spaces and 4 spaces indent.您混合了 2 个空格和 4 个空格缩进。 you should make them same.你应该让它们一样。 normally it should be 2 spaces.通常它应该是2个空格。
  2. the stage, script, and artifact should be in a new line, not in same line.舞台、脚本和工件应该在一个新行中,而不是在同一行中。

here is a possible fix这是一个可能的修复

image: openjdk:8-jdk

variables:
  ANDROID_COMPILE_SDK: "28"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "6609375_latest"

before_script:
  - echo ANDROID_COMPILE_SDK ${ANDROID_COMPILE_SDK}
  - echo ANDROID_BUILD_TOOLS ${ANDROID_BUILD_TOOLS}
  - echo ANDROID_SDK_TOOLS ${ANDROID_SDK_TOOLS}
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - export ANDROID_SDK_ROOT=$PWD/android-sdk-linux
  - export SDK_MANAGER="${ANDROID_SDK_ROOT}/tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT}"
  - echo y | ${SDK_MANAGER} "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | ${SDK_MANAGER} "platform-tools" >/dev/null
  - echo y | ${SDK_MANAGER} "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export PATH=$PATH:${ANDROID_SDK_ROOT}/platform-tools/
  - chmod +x ./gradlew
  # temporarily disable checking for EPIPE error and use yes to accept all licenses
  - set +o pipefail
  - echo y | ${SDK_MANAGER} --licenses
  - set -o pipefail

stages:
  - build
  - test
  - release

lintDebug:
  stage: build
  script:
    - ./gradlew -Pci --console=plain :app:lintDebug -PbuildDir=lint

assembleDebug:
  stage: build
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
      - app/build/outputs/

debugTests:
  stage: test
  script:
    - ./gradlew -Pci --console=plain :app:testDebug

assembleRelease:
  stage: release
  script:
    - echo $KEYSTORE_FILE | base64 -d > my.keystore
    - ./gradlew assembleRelease
      -Pandroid.injected.signing.store.file=$(pwd)/my.keystore
      -Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD
      -Pandroid.injected.signing.key.alias=$KEY_ALIAS
      -Pandroid.injected.signing.key.password=$KEY_PASSWORD
  artifacts:
    paths:
      - app/build/outputs/apk/release
      - CHANGELOG

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM