如何在AzureDevops中缓存sdkmanager? [英] How do you cache sdkmanager in AzureDevops?

查看:38
本文介绍了如何在AzureDevops中缓存sdkmanager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在管道中执行以下操作

I do the following in my pipeline

          - bash: |
              $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'ndk;20.0.5594570' >/dev/null
              $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'ndk;21.0.6113669' >/dev/null
            displayName: "install NDK"

大约需要3分钟

我想知道是否可以缓存它来加快速度.但是,我不确定它将文件放置在何处.

I was wondering if I can cache this to speed things up. However, I am not sure where it puts the files.

推荐答案

如上一个答案所述,应该使用 Cache @ 2 任务.根据下载ndk的注释路径,在 ANDROID_SDK_ROOT 中.需要注意的是,ANDROID_SDK_ROOT不是可立即访问的变量.它需要暴露.

As noted in a previous answer, the Cache@2 task is supposed to be used. And as per the comment path where the ndk is downloaded to is in ANDROID_SDK_ROOT. The thing to note is ANDROID_SDK_ROOT is not a variable that is immediately accessible. It needs to be exposed.

因此,将其与一个有效的示例放在一起:

So to put it all together with a working example:

steps:
- bash: |
    echo "##vso[task.setvariable variable=ANDROID_SDK_ROOT;]$ANDROID_SDK_ROOT"
- task: Cache@2
  inputs:
    key: 'ndk | "$(Agent.OS)"'
    path: $(ANDROID_SDK_ROOT)/ndk

- bash: |
    $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'ndk;20.0.5594570' >/dev/null
    $ANDROID_SDK_ROOT/tools/bin/sdkmanager 'ndk;21.0.6113669' >/dev/null
  displayName: "install NDK"

此技术可以在其他地方使用,这样您就可以获取与代理程序池无关的脚本,这些文件位于主目录中.适用于 macOS ubuntu 池.

This technique can be used in other places so that you'd get an agent pool agnostic script where the files are places in the home directory. Applies to both macOS and ubuntu pools.

steps:
- bash: |
    echo "##vso[task.setvariable variable=HOME_DIRECTORY;]$HOME"
- task: Cache@2
  inputs:
    key: 'gradlew | "$(Agent.OS)"'
    # this won't work on macOS
    # path: /home/vsts/.gradle/wrapper
    # but this will
    path: $(HOME_DIRECTORY)/.gradle/wrapper
- task: Cache@2
  inputs:
    key: 'gradle | "$(Agent.OS)"'
    path: $(HOME_DIRECTORY)/.gradle/caches

这篇关于如何在AzureDevops中缓存sdkmanager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆