我正在使用Azure Pipeline构建和运行iOS代码测试。这些步骤工作正常。如何在bitbucket中显示构建状态?
我可以找到一个script:
idpAddFile('https://mywebsite.com/download/app.bin', ExpandConstant('{tmp}\app.bin'));
但是使用带有#!/usr/bin/env python
import os
import requests
# Use environment variables that your CI server provides to the key, name,
# and url parameters, as well as commit hash. (The values below are used by
# Jenkins.)
data = {
'key': os.getenv('BUILD_ID'),
'state': 'SUCCESSFUL', # or 'FAILED' for a script that runs when the build fails
'name': os.getenv('JOB_NAME'),
'url': os.getenv('BUILD_URL'),
'description': 'The build passed.'
}
# Construct the URL with the API endpoint where the commit status should be
# posted (provide the appropriate owner and slug for your repo).
api_url = ('https://api.bitbucket.org/2.0/repositories/'
'%(owner)s/%(repo_slug)s/commit/%(revision)s/statuses/build'
% {'owner': 'emmap1',
'repo_slug': 'MyRepo',
'revision': os.getenv('GIT_COMMIT')})
# Post the status to Bitbucket. (Include valid credentials here for basic auth.
# You could also use team name and API key.)
requests.post(api_url, auth=('auth_user', 'auth_password'), json=data)
的python任务运行它给了我print 'job name: {}'.format(os.getenv("BUILD_ID"))
。如何获取状态显示在bitbucket中?
答案 0 :(得分:1)
Azure Pipeline中内部版本ID的变量为Build.BuildId
,因此只需将os.getenv("BUILD_ID")
替换为os.getenv("BUILD_BUILDID")
。
script: |
import os
id = os.getenv('BUILD_BUILDID')
print(id)
结果:
您可以查看here所有Azure Pipelines变量(在此处检查所需的其他变量)。