This is step-by-step guide for setting up a Azure DevOps pipeline to synchronize modified .feature
files from a Azure DevOps repository to the AssertThat plugin. This guide ensures that only modified feature files from the commit on which the pipeline is triggered are uploaded to AssertThat.
...
Code Block |
---|
trigger:
- main # Trigger the pipeline when changes are made to the main branch
pool:
vmImage: 'ubuntu-latest'
steps:
- script: |
# Set up Git with your Azure DevOps repository credentials
# Replace the following placeholders with actual values:
# - YOUR_AZURE_DEVOPS_REPO_URL
# - YOUR_AZURE_DEVOPS_USERNAME
# - YOUR_AZURE_DEVOPS_TOKEN
# Clone the Azure DevOps Git repository
git clone https://YOUR_AZURE_DEVOPS_USERNAME:YOUR_AZURE_DEVOPS_TOKEN@YOUR_AZURE_DEVOPS_REPO_URL .
displayName: 'Clone Azure DevOps Repository'
- script: |
# Set up Git with your AssertThat credentials
# Replace the following placeholders with actual values:
# - YOUR_ASSERTTHAT_ACCESS_KEY
# - YOUR_ASSERTTHAT_SECRET_KEY
# - YOUR_JIRA_HOST (AssertThat API endpoint, typically the Jira host)
# - YOUR_ASSERTTHAT_PROJECT_ID (the ID of your project in AssertThat)
# Get the list of modified .feature files in the commit
git diff --name-only HEAD^..HEAD | grep '\.feature$' > modified_features.txt
# Iterate through the modified .feature files and upload each one
while IFS= read -r file; do
curl -X POST \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Basic $(echo -n YOUR_ASSERTTHAT_ACCESS_KEY:YOUR_ASSERTTHAT_SECRET_KEY | base64)" \
-F "file=@$file" https://YOUR_JIRA_HOST/rest/assertthat/latest/project/YOUR_ASSERTTHAT_PROJECT_ID/client/upload?override=true
# NOTE: The example above is for Jira Data Center. In case you use cloud version the following URL should be used for uploading features: https://bdd.assertthat.app/rest/api/1/project/YOUR_ASSERTTHAT_PROJECT_ID/feature?override=true
done
displayName: 'Push Modified Feature Files to AssertThat'
# Additional steps can be added for testing and reporting as needed
|
Replace the placeholders with your specific Azure DevOps repository details, Azure DevOps credentials, AssertThat access key, AssertThat secret key, AssertThat API endpoint, and the project ID from AssertThat.NOTE: The example above is for Jira Data Center. In case you use cloud version the following URL should be used for uploading features:
https://bdd.assertthat. app/rest/api/1/project/YOUR_ASSERTTHAT_PROJECT_ID/feature?override=true
Step 3: Save and Run the Pipeline
...