如何在Azure管道中将版本转换为没有版本的字符串?

时间:2019-08-05 18:51:57

标签: python azure-pipelines

我确实有一些python版本参数,如下所示:

from couchbase.cluster import Cluster
from couchbase.cluster import PasswordAuthenticator
cluster = Cluster('couchbase://localhost')
authenticator = PasswordAuthenticator('username', 'password')
cluster.authenticate(authenticator)
cb = cluster.open_bucket('bucket-name')

在矩阵扩展期间,我做了parameters: pythonVersions: [2.7, 3.7, 3.6, 3.5] ,但后来我需要能够从python.version: ${{ version }}组成字符串py27,但是我找不到关于如何执行转换的文档。

python.version可以得到py2.7,而我需要去除点。我也尝试索引[0],但不支持。

1 个答案:

答案 0 :(得分:1)

可以肯定的是,没有内置的东西可以帮助您,您可以使用脚本步骤并执行sed魔术或类似于sed的操作,然后“导出”结果,这是我正在使用的示例:

- bash: |
    date=$(date --rfc-3339=ns | sed "s/ /T/; s/\(\....\).*-/\1-/g")
    echo "##vso[task.setvariable variable=CONTAINER_BUILD_TIME]$date"

然后,您可以在后续步骤中使用$(CONTAINER_BUILD_TIME)来访问在脚本步骤中设置的变量

相关问题