MaxMelcher / AzureDevOps.WikiPDFExport

Export Azure DevOps Wiki to PDF
MIT License
187 stars 62 forks source link

Build script not working in Azure DevOps #65

Closed Jheronymus closed 3 years ago

Jheronymus commented 3 years ago

I'm having trouble getting the build in Azure to work. It works fine on my local checkout. I can't use the rfennell extention in the marketplace as at seams it does not support Code wikis (only project wikis)

I've build up the pipeline step-by-step with the script. It worked ONCE. all the other runs fail on the script part with errors like this:

2021-06-02T15:36:18.0528843Z ##[section]Starting: PowerShell Script
2021-06-02T15:36:18.0681262Z ==============================================================================
2021-06-02T15:36:18.0681573Z Task         : PowerShell
2021-06-02T15:36:18.0681830Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-06-02T15:36:18.0682086Z Version      : 2.186.0
2021-06-02T15:36:18.0682296Z Author       : Microsoft Corporation
2021-06-02T15:36:18.0682604Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-06-02T15:36:18.0682968Z ==============================================================================
2021-06-02T15:36:20.7930688Z Generating script.
2021-06-02T15:36:20.8717439Z ========================== Starting Command Output ===========================
2021-06-02T15:36:20.9114822Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\3b50523b-dc7b-4cee-9638-a995b7239b67.ps1'"
2021-06-02T15:36:22.5996764Z 
2021-06-02T15:36:22.6190082Z Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                  
2021-06-02T15:36:22.6240776Z --     ----            -------------   -----         -----------     --------             -------                  
2021-06-02T15:36:22.6415061Z 1      013958c1-fe9...                 NotStarted    False                                ...                      
2021-06-02T15:37:26.6803427Z Invoke-WebRequest : Unable to read data from the transport connection: An existing connection was forcibly closed by 
2021-06-02T15:37:26.6845835Z the remote host.
2021-06-02T15:37:26.6846885Z At D:\a\_temp\3b50523b-dc7b-4cee-9638-a995b7239b67.ps1:20 char:1
2021-06-02T15:37:26.6848138Z + Invoke-WebRequest -Uri $url -OutFile $output
2021-06-02T15:37:26.6848812Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-06-02T15:37:26.6849487Z     + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], IOException
2021-06-02T15:37:26.6850322Z     + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
2021-06-02T15:37:26.6852175Z  
2021-06-02T15:37:26.8057192Z ##[error]PowerShell exited with code '1'.
2021-06-02T15:37:26.8806976Z ##[section]Finishing: PowerShell Script

Not a clue why. Next to that I've tried to 'update the URL to the latest version', but whatever I try, it always downloads a 41MB file, instead of the 17MB file that now is version 3.0.0

(I've not setup the publish artifact correctly, because the script does not succeed consistantly.) but here is yaml of the job:

pool:
  name: Azure Pipelines
steps:
- powershell: |
   #Download url to the export tool
   #!!! Update the url to the latest version!!!
   $url = "https://dev.azure.com/mmelcher/8036eca1-fd9e-4c0f-8bef-646b32fbda0b/_apis/git/repositories/e08d1ada-7794-4b89-a3ea-cb64a26683c3/Items?path=%2Fazuredevops-export-wiki.exe&versionDescriptor%5BversionOptions%5D=0&versionDescriptor%5BversionType%5D=0&versionDescriptor%5Bversion%5D=master&download=true&resolveLfs=true&%24format=octetStream&api-version=5.0-preview.1"

   #filename of the tool
   $output = "azuredevops-export-wiki.exe"

   #download the file
   Invoke-WebRequest -Uri $url -OutFile $output

   #launch the tool - adjust the parameters if required
   ./azuredevops-export-wiki.exe
  showWarnings: true
  workingDirectory: knowledgebase
  displayName: 'PowerShell Script'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

Any ideas or additional guidance?

MaxMelcher commented 3 years ago

fixed offline.

Updated the script to use the latest version directly from github, see Build Task.

Jheronymus commented 3 years ago

Thanks again Max. Small note, we also changed the output line in the script to pipe the export to the drop.

./azuredevops-export-wiki.exe -o $(Build.ArtifactStagingDirectory)\export.pdf