sed - 如何在 CircleCI 任务中访问构建 ID
问题描述
我正在尝试运行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}
解决方案
以下sed
命令有效。
- run:
name: testing env vars
command: sed "s/_buildNum/${CIRCLE_BUILD_NUM}/g" -i build.gradle
推荐阅读
- c# - 将 JSON 转换为 C# 对象数组
- javascript - 使用状态挂钩 - (状态变量)未定义 no-undef
- asp.net-mvc - 更改控制器 asp.net core 中的模型值
- python-requests - 带有 Python 获取请求的莫名其妙的 403 错误
- hadoop - 当很多hive任务排队时,我得到一个奇怪的错误:org.apache.thrift.transport.TTransportException
- sql - 从一张表中获得多项选择
- r - 使用 stringr 提取包含特定字符集的字符串中的整个单词
- sharepoint - 添加目标受众时,Sharepoint 组未显示
- ios - .subscribe(onSuccess/onError) 没有被调用
- swift - Swift 中的 iOS 编程和内存管理