Azure DevOps (Azure DevOps as master)
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.
Prerequisites:
Access to Azure DevOps.
An existing Azure DevOps repository.
Access to your Jira instance with the admin permissions to projects.
Your Jira project's
ASSERTTHAT_ACCESS_KEY
andASSERTTHAT_SECRET_KEY
, which can be obtained from the AssertThat project configuration.Your Jira project's
PROJECT_ID
, which you can obtain from AssertThat project configuration.
Step 1: Create an Azure DevOps Pipeline
1.1. Go to your Azure DevOps project and select "Pipelines" from the left navigation menu.
1.2. Click "New Pipeline" to create a new pipeline.
1.3. Select the existing Azure DevOps repository where you want to store the pipeline configuration.
1.4. Choose a template for your pipeline. You can select an appropriate template depending on your project requirements. For this example, choose "Starter pipeline" to get a basic YAML configuration.
1.5. Edit the pipeline YAML file.
Step 2: Define the Azure DevOps Pipeline
Define your Azure DevOps pipeline YAML to automate the synchronization of modified .feature
files from your Azure DevOps Git repository to AssertThat. Here's a detailed example with explanations:
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.
Step 3: Save and Run the Pipeline
Save the pipeline YAML file in your existing Azure DevOps repository. Trigger the pipeline by making changes to your main branch or by manually running it from the Azure DevOps interface.
With this pipeline in place, it will clone your Azure DevOps Git repository, identify the modified .feature
files in the commit on which the pipeline was triggered, and then upload them to AssertThat, ensuring the synchronization of modified feature files.