Azure DevOps pipeline task to update a file and check-in TFS

前端 未结 2 2017
轻奢々
轻奢々 2021-01-27 05:31

I\'m using the Azure Dev OPS to trigger the build and deploy. I have angular code in GIT branch from which the build will be triggered and based on build# I need to update a fil

2条回答
  •  遥遥无期
    2021-01-27 06:25

    Based on the above suggestions. I have added the below mentioned code

    $requestBody = @{
    changes=
      @(@{
        item= @{
          path= "$/SMT_Project/" + $branch + "/SMT/BPOSE_WebApp/Deal/LandingPage.aspx"
          contentMetadata= @{
            encoding= -1
          }
        }
        changeType= "add"
        newContent= @{
          content= $EncodedText
          contentType= "base64Encoded"
        }
      })
      comment= "Updated LandingPage.aspx with script for deployment"
      } | ConvertTo-Json -Depth 4
    $headers = @{
        Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
    }
    
    $headers.Add("Accept", 'application/json')
    
    $requestBodyJson = ($requestBody | ConvertFrom-Json)
    
    Write-Host 'headers - ' $headers
    Write-Host 'requestBody - ' $requestBody
    Write-Host 'requestBodyJson - ' $requestBodyJson
    
    $postRes = Invoke-WebRequest -Uri https://dev.azure.com/sm10/_apis/tfvc/changesets?api-version=5.1 -ContentType "application/json" -Headers $headers -Method POST -Body $requestBody -Verbose
    

    But I have not received and response from the web request also I have not received any errors. Please do let me know anything is missing.

提交回复
热议问题