Skip to content

Commit

Permalink
Merge branch 'develop' into feature/xx-test-trigger-from-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
svelderrainruiz committed Dec 11, 2024
2 parents 0cede35 + a9dfd1e commit 4e8dc1c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/trigger-azure-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,41 @@ jobs:
PAT="${{ secrets.AZURE_DEVOPS_PAT }}"
ORG="sergiovelderrain"
PROJECT="sergiovelderrain"
PIPELINE_ID="1"
API_VERSION="6.0-preview.1"
PIPELINE_ID="3"
# You can try a more recent api-version, for example "7.1-preview.1".
API_VERSION="7.1-preview.1"
# Ensure PAT is not empty
if [ -z "$PAT" ]; then
echo "AZURE_DEVOPS_PAT is not set or empty!"
exit 1
fi
# Base64 encode credentials
# Base64 encode the PAT for Basic auth
AUTH=$(echo -n ":$PAT" | base64)
# Use the PR's head ref for the pipeline branch
# Extract the PR branch name from the event.
# For a forked PR, this is something like: <branch_name>
# We'll need to prepend refs/heads/ for Azure DevOps.
PR_HEAD_REF="${{ github.event.pull_request.head.ref }}"
JSON_BODY='{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/'"${PR_HEAD_REF}"'"
# Construct the JSON payload with properly escaped quotes.
# Using double-quotes around the entire JSON and escaping internal quotes is safest.
JSON_BODY="{
\"resources\": {
\"repositories\": {
\"self\": {
\"refName\": \"refs/heads/${PR_HEAD_REF}\"
}
}
}
}'
}"
echo "Triggering Azure DevOps pipeline with the following JSON:"
echo "$JSON_BODY"
# Use --http1.1 to avoid HTTP/2 related issues, remove -s for verbosity
curl --http1.1 -v -X POST \
# Use --http1.1 and -v for verbose output to help debug issues if any.
# Add --fail to ensure the command fails if we get a non-2xx response.
curl --http1.1 --fail -v -X POST \
-H "Authorization: Basic $AUTH" \
-H "Content-Type: application/json" \
-d "$JSON_BODY" \
Expand Down
33 changes: 14 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
# Removed trigger so pipeline runs only when requested via API
# trigger:
# branches:
# include:
# - main
# - develop
trigger: none
pr: none

name: $(Build.BuildID)
name: $(Build.BuildId)

pool:
name: "Default"
demands: "iconeditor -equals true"
demands:
- iconeditor -equals true

variables:
build_id: $(Build.BuildID)
build_revision: $[counter('buildCounter',1)]
build_version: '1.0.$(Build.BuildID).$(build_revision)'
build_id: $(Build.BuildId)
build_revision: $[counter('buildCounter', 1)]
build_version: '1.0.$(Build.BuildId).$(build_revision)'
RelativePath: '$(Build.SourcesDirectory)'
RelativePathScripts: '$(Build.SourcesDirectory)\pipeline\scripts'

stages:
- stage: BuildAndTest
displayName: Build and Test LabVIEW Project
displayName: "Build and Test LabVIEW Project"
jobs:
- job: ExecuteScripts
displayName: Execute Scripts
displayName: "Execute Scripts"
steps:
- task: PowerShell@2
displayName: 'Set agent into development mode'
displayName: "Set agent into development mode"
inputs:
filePath: '$(RelativePathScripts)\Set_Development_Mode.ps1'
arguments: '-RelativePath "$(RelativePath)"'
Expand All @@ -35,12 +32,10 @@ stages:
errorActionPreference: 'Stop'

- task: PowerShell@2
displayName: 'Test and Build the Icon Editor'
displayName: "Test and Build the Icon Editor"
inputs:
filePath: '$(RelativePathScripts)\Build.ps1'
arguments: >
-RelativePath "$(RelativePath)"
-AbsolutePathScripts "$(RelativePathScripts)"
arguments: '-RelativePath "$(RelativePath)" -AbsolutePathScripts "$(RelativePathScripts)"'
workingDirectory: '$(RelativePathScripts)'
failOnStderr: true
errorActionPreference: 'Stop'
errorActionPreference: 'Stop'

0 comments on commit 4e8dc1c

Please sign in to comment.