我确实有一些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],但不支持。
答案 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)
来访问在脚本步骤中设置的变量