refs TG-3: build Windows Qt
This commit is contained in:
Vendored
+49
-42
@@ -48,68 +48,75 @@ pipeline {
|
|||||||
def result = currentBuild.currentResult ?: 'UNKNOWN'
|
def result = currentBuild.currentResult ?: 'UNKNOWN'
|
||||||
|
|
||||||
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
|
withCredentials([string(credentialsId: 'TAIGA_TOKEN', variable: 'TAIGA_TOKEN')]) {
|
||||||
powershell(returnStatus: true, script: """
|
writeFile file: 'taiga-post.ps1', text: '''
|
||||||
\$commitMsg = git log -1 --pretty=%B
|
$ErrorActionPreference = "Continue"
|
||||||
\$match = [regex]::Match(\$commitMsg, 'TG-(\\d+)')
|
|
||||||
|
|
||||||
if (-not \$match.Success) {
|
$commitMsg = git log -1 --pretty=%B
|
||||||
|
$match = [regex]::Match($commitMsg, 'TG-(\\d+)')
|
||||||
|
|
||||||
|
if (-not $match.Success) {
|
||||||
Write-Host "No TG-* reference found"
|
Write-Host "No TG-* reference found"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
\$ref = \$match.Groups[1].Value
|
$ref = $match.Groups[1].Value
|
||||||
\$headers = @{
|
|
||||||
Authorization = "Bearer \$env:TAIGA_TOKEN"
|
$headers = @{
|
||||||
|
Authorization = "Bearer $env:TAIGA_TOKEN"
|
||||||
"Content-Type" = "application/json"
|
"Content-Type" = "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
\$targets = @(
|
$targets = @(
|
||||||
@{ endpoint = "userstories"; label = "User Story" },
|
@{ endpoint = "userstories"; label = "User Story" },
|
||||||
@{ endpoint = "issues"; label = "Issue" },
|
@{ endpoint = "issues"; label = "Issue" },
|
||||||
@{ endpoint = "tasks"; label = "Task" }
|
@{ endpoint = "tasks"; label = "Task" }
|
||||||
)
|
)
|
||||||
|
|
||||||
\$found = \$null
|
$found = $null
|
||||||
|
|
||||||
foreach (\$target in \$targets) {
|
foreach ($target in $targets) {
|
||||||
try {
|
try {
|
||||||
\$url = "\$env:TAIGA_URL/api/v1/\$(\$target.endpoint)/by_ref?project=\$env:TAIGA_PROJECT_ID&ref=\$ref"
|
$url = "$env:TAIGA_URL/api/v1/$($target.endpoint)/by_ref?project=$env:TAIGA_PROJECT_ID&ref=$ref"
|
||||||
\$data = Invoke-RestMethod -Uri \$url -Headers \$headers -Method Get
|
$data = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
|
||||||
if (\$data.id) {
|
if ($data.id) {
|
||||||
\$found = @{
|
$found = @{
|
||||||
endpoint = \$target.endpoint
|
endpoint = $target.endpoint
|
||||||
label = \$target.label
|
label = $target.label
|
||||||
data = \$data
|
data = $data
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Taiga lookup warning: \$($_.Exception.Message)"
|
Write-Host "Taiga lookup warning: $($_.Exception.Message)"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (-not \$found) {
|
if (-not $found) {
|
||||||
Write-Host "Taiga TG-\$ref not found"
|
Write-Host "Taiga TG-$ref not found"
|
||||||
exit 0
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
$comment = "Jenkins Windows Qt build #$env:BUILD_NUMBER: $env:BUILD_RESULT`n$env:BUILD_URL"
|
||||||
|
|
||||||
|
$body = @{
|
||||||
|
comment = $comment
|
||||||
|
version = $found.data.version
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
try {
|
||||||
|
$url = "$env:TAIGA_URL/api/v1/$($found.endpoint)/$($found.data.id)"
|
||||||
|
Invoke-RestMethod -Uri $url -Headers $headers -Method Patch -Body $body
|
||||||
|
Write-Host "Commented Taiga TG-$ref ($($found.label))"
|
||||||
|
} catch {
|
||||||
|
Write-Host "Taiga comment warning: $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
'''
|
||||||
|
|
||||||
|
withEnv(["BUILD_RESULT=${result}"]) {
|
||||||
|
powershell(returnStatus: true, file: 'taiga-post.ps1')
|
||||||
}
|
}
|
||||||
|
|
||||||
\$comment = "Jenkins Windows Qt build #$env:BUILD_NUMBER: ${result}`n$env:BUILD_URL"
|
|
||||||
|
|
||||||
\$body = @{
|
|
||||||
comment = \$comment
|
|
||||||
version = \$found.data.version
|
|
||||||
} | ConvertTo-Json
|
|
||||||
|
|
||||||
try {
|
|
||||||
\$url = "\$env:TAIGA_URL/api/v1/\$(\$found.endpoint)/\$(\$found.data.id)"
|
|
||||||
Invoke-RestMethod -Uri \$url -Headers \$headers -Method Patch -Body \$body
|
|
||||||
Write-Host "Commented Taiga TG-\$ref (\$(\$found.label))"
|
|
||||||
} catch {
|
|
||||||
Write-Host "Taiga comment warning: \$($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
""")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user