0

我正在尝试运行sed命令来替换指示当前构建 ID 的环境变量。根据文档CIRCLE_BUILD_NUM包含我正在寻找的值,根据这个例子,它应该非常容易在command.

下面是配置文件,下面是正在执行命令的bundle.gradle文件,下面是结果。sed如您所见,该sed命令只是CIRCLE_BUILD_NUM将其视为字符串而不是获取内部版本号。

配置.yml

version: 2.1

orbs:
android: circleci/android@0.2.0

jobs:
build:
  executor: android/android

  steps:
    - checkout
    - setup_remote_docker: 
        docker_layer_caching: true      
    - run:
        name: testing env vars
        command: sed 's/${BUILD_NUM_1}/${CIRCLE_BUILD_NUM}/g' -i build.gradle 

捆绑包.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
def buildNum = ${BUILD_NUM_1}

输出

// Top-level build file where you can add configuration options common to all sub-projects/modules.
def buildNum = ${CIRCLE_BUILD_NUM}
4

1 回答 1

0

以下sed命令有效。

 - run:
     name: testing env vars
     command: sed "s/_buildNum/${CIRCLE_BUILD_NUM}/g" -i build.gradle 
于 2020-06-15T17:25:48.717 回答