简体   繁体   中英

Bash on Azure Pipeline running windows agent

I'm trying to get a build number from a secondary Azure pipeline. I'm using bash on a windows agent, already enabled developer mode, and installed the Linux feature. When I test this locally it works, I'm able to connect and get the build number but from the pipeline, I get the error...

Enhanced Security Configuration is currently enabled on your environment. This enhanced level of security prevents our web integration experiences from displaying or performing correctly. To continue with your operation please disable this configuration or contact your administrator

Could it be related to the Auth system token? I have also enabled "Allow scripts to access the OAuth token"

Bash code that I'm trying to use on the pipeline:

 #./bin/bash echo $TAG echo $VER echo $SYSTEM_ACCESSTOKEN echo "Executing call to get latest build from a pipeline definition Id" echo "$URL-7:1" export RESPONSE=`curl -u username".$SYSTEM_ACCESSTOKEN" --location --request GET "$URLapi-version=7.1-preview.1"` echo $RESPONSE export BUILD_NUMBER=`echo $RESPONSE | jq -r '.["buildNumber"]'` echo $BUILD_NUMBER

Powershell script working locally, but if I use this form, the access token is not recognized.

 $connectionToken= $(System.AccessToken) $base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)")) $BuildPipelineUrl = "$url`$top=1&api-version=6.0" Write-Host "URL: $BuildPipelineUrl" $BuildPipelineInfo = (Invoke-RestMethod -Uri $BuildPipelineUrl -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}) $ver = $BuildPipelineInfo.value.buildnumber Write-Host "$ver"

Is there another way to use the Sys auth token, Do I have to convert it?

Thanks, everyone..

You could try to use the following powershell script to check if it works.

$Token = $env:SYSTEM_ACCESSTOKEN
$BuildPipelineUrl = "$url`$top=1&api-version=6.0" 

Write-Host "URL: $BuildPipelineUrl"

$BuildPipelineInfo = (Invoke-RestMethod -Uri $BuildPipelineUrl -Method Get -Headers @{ Authorization = "Bearer $Token" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM