3.3 KiB
3.3 KiB
Programming language recommendations
Azure DevOps Pipeline
The following programming languages are included in the comparison:
- C# (.NET)
- Shell Scripting Bash / Zsh
- Python
- JavaScript / TypeScript
- Ruby
- Go
- PowerShell
- Java
Comparsion of the most important points
| Point | C# | Shell | Python | JS | Ruby | Go | PS | Java |
|---|---|---|---|---|---|---|---|---|
| Data processing (JSON) | Built-in | Built-in | Built-in | Built-in | Built-in | Built-in | Built-in | Libraries |
| Data presentation (PDF) | Libraries | Not natively | Libraries | Libraries | Libraries | Libraries | Libraries | Libraries |
| Other data processing | Libraries | Not natively | Libraries | Libraries | Libraries | Libraries | Libraries | Libraries |
| Availability of Extensions | Many | Few | Many | Many | Many | Few | Many | Many |
| Simplicity in YAML | Moderate | High | Moderate | Moderate | Moderate | High | High | Moderate |
| Must be Compiled | Yes | No | No | No | No | Yes | No | Yes |
| Cross-Platform | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| Simple Installation of Dependencies | Moderate | High | High | High | Moderate | High | High | Moderate |
Recommended Language: Python
Python wins in all categories. The most benefits compared to the other languages:
- Data Handling: pull data, parse it, and then format it.
- Document Generation: The libraries for data presentation are fast and simple.
- Dependencies: are easy handled with requirments.txt.
- Virtual Environments: allows different Python versions to be used in the same pipeline.
- REST APIs: can be simple used with the Pythons requests library.
Example Workflows for Python
Install Dependencies
Use a pipeline task to install Python (if not already on the agent) and the required libraries.
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
- script: |
pip install requests python-docx reportlab jinja2
Fetch Work Items
Write a Python script to call the Azure DevOps REST API to retrieve Work Items.
import requests
# Example: Get Work Items from Azure DevOps
devops_organization_url = "https://dev.azure.com/YOUR_ORG"
project = "YOUR_PROJECT"
api_version = "6.0"
query_id = "YOUR_QUERY_ID"
response = requests.get(
f"{devops_organization_url}/{project}/_apis/wit/wiql/{query_id}?api-version={api_version}",
auth=('PAT_USERNAME', 'PAT_TOKEN') # or use other Auth methods
)
work_items_data = response.json()
Generate Compliance Documents
Convert the retrieved data into the document format of your choice.
from docx import Document
from docx.shared import Inches
document = Document()
document.add_heading('Compliance Report', level=1)
for item in work_items_data["workItems"]:
document.add_heading(f'Work Item ID: {item["id"]}', level=2)
# Additional data insertion here...
document.save('ComplianceReport.docx')