代码之家  ›  专栏  ›  技术社区  ›  NickUnuchek Romulano

如何在管道中缓存lib?

  •  0
  • NickUnuchek Romulano  · 技术社区  · 5 年前

    这是我的 bitbucket-pipelines.yml android项目文件:

    # This is a sample build configuration for Java (Gradle).
    # Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
    # Only use spaces to indent your .yml configuration.
    # -----
    # You can specify a custom docker image from Docker Hub as your build environment.
    image: java:8
    
    pipelines:
      branches:
        '{master}':
        - step:
            caches:
            - gradle
            - android-sdk
    
            script:
            # Download and unzip android sdk
            - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
            - unzip -o -qq android-sdk.zip -d android-sdk
    
            # Define Android Home and add PATHs
            - export ANDROID_HOME="/opt/atlassian/pipelines/agent/build/android-sdk"
            - export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
    
            # Download packages.
            - yes | sdkmanager "platform-tools"
            - yes | sdkmanager "platforms;android-19"
            - yes | sdkmanager "platforms;android-23"
            - yes | sdkmanager "platforms;android-28"
            - yes | sdkmanager "build-tools;27.0.3"
            - yes | sdkmanager "build-tools;28.0.3"
            - yes | sdkmanager "extras;android;m2repository"
            - yes | sdkmanager "extras;google;m2repository"
            - yes | sdkmanager "extras;google;instantapps"
            - yes | sdkmanager --licenses
    
            # Build apk
            - echo “Start default step”
            - # Add Android SDK license in the default file
            - mkdir "${ANDROID_HOME}/licenses" || true
            - echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
            - echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > $ANDROID_HOME/licenses/android-sdk-license
    
              # Build the app
            - chmod a+x gradlew
            - ./gradlew assembleDebug
            - echo "Amazing"
    
    
    definitions:
      caches:
        android-sdk: android-sdk
        gradle: gradle
    

    但是当我重新运行脚本时,它总是下载libs进行构建:

    Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
    ..............................................................................................
    Unzipping /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4-all.zip to /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1
    Set executable permissions for: /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4/bin/gradle
    Starting a Gradle Daemon (subsequent builds will be faster)
    Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom
    Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.61/kotlin-gradle-plugin-1.2.61.pom
    Download https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.1.0-alpha01/bundletool-0.1.0-alpha01.pom
    Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-core/3.1.4/gradle-core-3.1.4.pom
    

    是否有任何方式避免重新下载项目的LIBs,可能存在一个缓存和解压缩它们的案例,比如“Android SDK”和“Gealle”?

    0 回复  |  直到 5 年前