Coder Social home page Coder Social logo

microsoft / azure-devops-python-samples Goto Github PK

View Code? Open in Web Editor NEW
98.0 19.0 81.0 36 KB

Python samples for interacting with and managing Azure DevOps

Home Page: https://azure.microsoft.com/services/devops/

License: MIT License

Jupyter Notebook 13.37% Python 86.63%
python vsts api samples

azure-devops-python-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-devops-python-samples's Issues

Samples are rather limited

Hi,

The main API is great and it is nice to have some sample code. However, I have just found 2 examples for workitems and 2 for Git.

Am I missing something?

Also, I cannot find anything on how to use WIQL queries with the API.

Thanks

Setting up config for the first time gets misleading warning

Screen Shot 2020-04-23 at 8 41 38 PM

Logging a tiny usability bug:

Getting the above output when I was setting the config. Specifically

The default filename has changed. You may need to rename
vsts-runner-config.json
to
azure-devops-runner-config.json

That warning msg will show up for everybody who's setting up the config for the first time, since azure-devops-runner-config.json has yet been created, which is misleading.

Get test result for a specific test case

In .../samples/test.py, you have a function, def get_test_results(context):

This appears to get all of the test results for a given context. Is it possible to get the test result of a single test case?

Azur DevOps throws ValueError: Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version

Hi,

Agent pool : Windows
Installed Chrome Version : 85.0.1483.103

When i run the Pytests, it throws "ValueError: Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version "

Dev Ops has confirmed Windows agent has Chrome.

We are stuck here,cannot move forward.

Could some one please shed the lights!

Locally, works fine

2020-09-09T17:11:18.2185128Z ##[section]Starting: Run smoke_test copy
2020-09-09T17:11:18.2391733Z ==============================================================================
2020-09-09T17:11:18.2392103Z Task : Command line
2020-09-09T17:11:18.2392268Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2020-09-09T17:11:18.2392446Z Version : 2.164.2
2020-09-09T17:11:18.2392574Z Author : Microsoft Corporation
2020-09-09T17:11:18.2392757Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2020-09-09T17:11:18.2392882Z ==============================================================================
2020-09-09T17:11:19.3860400Z Generating script.
2020-09-09T17:11:19.4228320Z ========================== Starting Command Output ===========================
2020-09-09T17:11:19.4483483Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "F:\XXX-vsts-agent-2_work_temp\f3ac2905-7c4a-40ef-a58b-c37a21431ffc.cmd""
2020-09-09T17:11:20.4105411Z Package Version
2020-09-09T17:11:20.4106029Z --------------------- ---------
2020-09-09T17:11:20.4106901Z ansi2html 1.5.2
2020-09-09T17:11:20.4108199Z apipkg 1.5
2020-09-09T17:11:20.4108775Z atomicwrites 1.4.0
2020-09-09T17:11:20.4110321Z attrs 20.2.0
2020-09-09T17:11:20.4110860Z certifi 2020.6.20
2020-09-09T17:11:20.4112407Z chardet 3.0.4
2020-09-09T17:11:20.4112925Z colorama 0.4.3
2020-09-09T17:11:20.4114389Z configparser 5.0.0
2020-09-09T17:11:20.4114959Z crayons 0.4.0
2020-09-09T17:11:20.4116475Z docutils 0.16
2020-09-09T17:11:20.4116853Z execnet 1.7.1
2020-09-09T17:11:20.4118407Z htmlmin 0.1.12
2020-09-09T17:11:20.4118897Z idna 2.10
2020-09-09T17:11:20.4120404Z iniconfig 1.0.1
2020-09-09T17:11:20.4120942Z Jinja2 2.11.2
2020-09-09T17:11:20.4122443Z jsonschema 3.2.0
2020-09-09T17:11:20.4122990Z MarkupSafe 1.1.1
2020-09-09T17:11:20.4124497Z more-itertools 8.5.0
2020-09-09T17:11:20.4125054Z msgpack 1.0.0
2020-09-09T17:11:20.4126496Z numpy 1.19.1
2020-09-09T17:11:20.4127190Z packaging 20.4
2020-09-09T17:11:20.4128715Z pandas 1.1.2
2020-09-09T17:11:20.4129630Z pip 20.1.1
2020-09-09T17:11:20.4131451Z pluggy 0.13.1
2020-09-09T17:11:20.4132120Z py 1.9.0
2020-09-09T17:11:20.4132672Z pyparsing 2.4.7
2020-09-09T17:11:20.4133276Z pyrsistent 0.16.0
2020-09-09T17:11:20.4134242Z pytest 6.0.1
2020-09-09T17:11:20.4134770Z pytest-azurepipelines 0.8.0
2020-09-09T17:11:20.4160614Z pytest-colordots 1.1
2020-09-09T17:11:20.4161603Z pytest-forked 1.3.0
2020-09-09T17:11:20.4162070Z pytest-html 2.1.1
2020-09-09T17:11:20.4162463Z pytest-metadata 1.10.0
2020-09-09T17:11:20.4162873Z pytest-ordering 0.6
2020-09-09T17:11:20.4163243Z pytest-reporter 0.4.0
2020-09-09T17:11:20.4163626Z pytest-reporter-html1 0.7.0
2020-09-09T17:11:20.4163994Z pytest-xdist 2.1.0
2020-09-09T17:11:20.4164382Z python-dateutil 2.8.1
2020-09-09T17:11:20.4164765Z python-json-config 1.2.3
2020-09-09T17:11:20.4165133Z pytz 2020.1
2020-09-09T17:11:20.4165634Z requests 2.24.0
2020-09-09T17:11:20.4166026Z selenium 3.141.0
2020-09-09T17:11:20.4166703Z setuptools 47.1.0
2020-09-09T17:11:20.4167116Z six 1.15.0
2020-09-09T17:11:20.4167546Z substring 0.2
2020-09-09T17:11:20.4167958Z toml 0.10.1
2020-09-09T17:11:20.4168388Z urllib3 1.25.10
2020-09-09T17:11:20.4169418Z webdriver-manager 3.2.2
2020-09-09T17:11:20.4750689Z WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
2020-09-09T17:11:20.4751236Z You should consider upgrading via the 'c:\program files (x86)\python38-32\python.exe -m pip install --upgrade pip' command.
2020-09-09T17:11:22.3209924Z ============================= test session starts =============================
2020-09-09T17:11:22.3212494Z platform win32 -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
2020-09-09T17:11:22.3361227Z rootdir: F:\xxxx-vsts-agent-2_work\18\s\Tests, configfile: pytest.ini
2020-09-09T17:11:22.3361685Z plugins: azurepipelines-0.8.0, colordots-1.1, forked-1.3.0, html-2.1.1, metadata-1.10.0, ordering-0.6, reporter-0.4.0, reporter-html1-0.7.0, xdist-2.1.0
2020-09-09T17:11:22.3415903Z gw0 I / gw1 I / gw2 I / gw3 I / gw4 I
2020-09-09T17:11:25.4888327Z collected 7 items / 1 deselected / 6 selected
2020-09-09T17:11:27.7173269Z gw0 [6] / gw1 [6] / gw2 [6] / gw3 [6] / gw4 [6]
2020-09-09T17:11:27.7173855Z
2020-09-09T17:11:29.9637114Z ##[error]12 test(s) failed, 6 test(s) collected.
2020-09-09T17:11:29.9644764Z Skipping uploading of coverage data.
2020-09-09T17:11:29.9645049Z
2020-09-09T17:11:29.9648336Z =================================== ERRORS ====================================
2020-09-09T17:11:29.9654309Z _ ERROR at setup of Test_PayrollAccountant.test_Employee_TC_For_Regular_Week_Wit_Allowance_Rejected_By_PA _
2020-09-09T17:11:29.9654900Z [gw4] win32 -- Python 3.8.5 c:\program files (x86)\python38-32\python.exe
2020-09-09T17:11:29.9655182Z
2020-09-09T17:11:29.9655477Z request = <SubRequest 'setup' for >
2020-09-09T17:11:29.9655716Z
2020-09-09T17:11:29.9655953Z @pytest.fixture()
2020-09-09T17:11:29.9656193Z def setup(request):
2020-09-09T17:11:29.9656433Z url = str(ReadConfig.getApplicationURL())
2020-09-09T17:11:29.9656691Z DefinedBrowser = ReadConfig.getBrowser()
2020-09-09T17:11:29.9656959Z global driver
2020-09-09T17:11:29.9657198Z if DefinedBrowser.lower() == "chrome":
2020-09-09T17:11:29.9657458Z # driver=webdriver.Chrome("./Configurations/Browser_Drivers/chromedriver.exe")
2020-09-09T17:11:29.9657729Z > driver = webdriver.Chrome(ChromeDriverManager().install())
2020-09-09T17:11:29.9657951Z
2020-09-09T17:11:29.9658196Z Tests\conftest.py:20:
2020-09-09T17:11:29.9658445Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2020-09-09T17:11:29.9658728Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\chrome.py:23: in init
2020-09-09T17:11:29.9659005Z self.driver = ChromeDriver(name=name,
2020-09-09T17:11:29.9659263Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\driver.py:54: in init
2020-09-09T17:11:29.9659536Z self.browser_version = chrome_version(chrome_type)
2020-09-09T17:11:29.9659799Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
2020-09-09T17:11:29.9660034Z
2020-09-09T17:11:29.9660260Z browser_type = 'google-chrome'
2020-09-09T17:11:29.9660484Z
2020-09-09T17:11:29.9660725Z def chrome_version(browser_type=ChromeType.GOOGLE):
2020-09-09T17:11:29.9660964Z pattern = r'\d+.\d+.\d+'
2020-09-09T17:11:29.9661276Z
2020-09-09T17:11:29.9661529Z cmd_mapping = {
2020-09-09T17:11:29.9661779Z ChromeType.GOOGLE: {
2020-09-09T17:11:29.9662026Z OSType.LINUX: 'google-chrome --version || google-chrome-stable --version',
2020-09-09T17:11:29.9662302Z OSType.MAC: r'/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version',
2020-09-09T17:11:29.9662579Z OSType.WIN: r'reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version'
2020-09-09T17:11:29.9662827Z },
2020-09-09T17:11:29.9663073Z ChromeType.CHROMIUM: {
2020-09-09T17:11:29.9663797Z OSType.LINUX: 'chromium --version || chromium-browser --version',
2020-09-09T17:11:29.9664095Z OSType.MAC: r'/Applications/Chromium.app/Contents/MacOS/Chromium --version',
2020-09-09T17:11:29.9665293Z OSType.WIN: r'reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" /v version'
2020-09-09T17:11:29.9665603Z },
2020-09-09T17:11:29.9665849Z ChromeType.MSEDGE: {
2020-09-09T17:11:29.9666118Z OSType.MAC: r'/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version',
2020-09-09T17:11:29.9666392Z OSType.WIN: r'reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Edge\BLBeacon" /v version',
2020-09-09T17:11:29.9666646Z }
2020-09-09T17:11:29.9666886Z }
2020-09-09T17:11:29.9667218Z
2020-09-09T17:11:29.9667449Z cmd = cmd_mapping[browser_type][os_name()]
2020-09-09T17:11:29.9667680Z stdout = os.popen(cmd).read()
2020-09-09T17:11:29.9667924Z version = re.search(pattern, stdout)
2020-09-09T17:11:29.9668150Z if not version:
2020-09-09T17:11:29.9668391Z > raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
2020-09-09T17:11:29.9668658Z E ValueError: Could not get version for Chrome with this command: reg query
"HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
2020-09-09T17:11:29.9668917Z
2020-09-09T17:11:29.9669153Z C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Python\Python38\site-packages\webdriver_manager\utils.py:142: ValueError

Please see the below screenshots

image

image

image

image

There are no tests

The samples need a set of tests so that we can safely make runner/framework changes, and so we can run against new versions of the VSTS API.

Sample for create test run and update test run result for particular test-points

Firstly Thanks for you support and effort .

I am started understanding version 5.1. It bit difficult to understand method as there no sample for the most of method.
Request here is, Do we have any documentation on how to use method in packages. like (pandas or flask). ? If Yes Could you please share us that documentation link.
if no, Could you please help us on this to method and usages especially on "Test"

Add support of Azure DevOps version 5.0 / 5.1

Module vsts for VSTS / TFS has been replaced by azure-devops (https://github.com/Microsoft/azure-devops-python-api) with versions 5.0 and 5.1 of the API.

The code has been reworked; for example, the following:

from vsts.vss_connection import VssConnection
connection = VssConnection(base_url=team_instance, creds=credentials)
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')

has been replaced by:

from azure.devops.connection import Connection
connection = Connection(base_url=organization_url, creds=credentials)
core_client = connection.clients.get_core_client()

It should be considered to have both versions available in the example (and set via a variable in the configuration). Or at least the latest version.

Example of function `create_attachment`

Hi (and Happy New Year),

I am working on improving the examples for create_attachment functions and related functionalities (e.g. add attachment to step or retrieving list of attachments for a Test Case).

Could you tell me actually what is the stream for the create_attachment function?

    def create_attachment(self, upload_stream, project=None, file_name=None, upload_type=None, area_path=None):
        """CreateAttachment.
        Uploads an attachment.
        :param object upload_stream: Stream to upload
        ...
        """

I tried both solutions below but none seems to work:

with open('./smiley.png', "rb") as f:
    binary_content = bytes(f.read())
attachment = client_wit.create_attachment(binary_content, project, 'smiley.png')
attachment = client_wit.create_attachment("Hello my friend", project, 'test6.txt')

(this solution creates a text file but it contains the double quotes in the text)

Thanks

this breaks at the first step

running the command python3 -m venv env && . env/bin/activate && pip install -r requirements.txt just wont go past. I have tried to break the command into parts. but then there is no correct path for env/bin/activate. the activate is in the Scripts folder. but running it from there gives another "deactivate { " error. can you provide resolution for this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.