powershellazure-devopsazure-cliazure-devops-wiki

How to Create New Lines of Content on Update Azure DevOps Wiki on CLI Command Line


I'm trying to create a table in Azure DevOps Wiki using the Azure CLI command az DevOps wiki page update. The value of the --content parameter that I'm sending contains \n which I'm led to believe creates a new line in the wiki page, but it doesn't seem to work, instead, it looks like this:enter image description here

The --content parameter value looks like this:

"# Main Heading\n\n## Subheading\n\n| **Column Header**          | **Header 1** | **Header 2** | **Header 3** |  **Header 4** | **Header 5**    |\n| -----------------      | ------- | ------- | ------- | -------- | ---------- |\n| Item 1 | 1.1.1 | 1.1.1 | 1.1.1 | 1.1.1 | **1.1.1** |\n| Item 2 | 2.2.2 | 2.2.2 | 2.2.2 | 2.2.2 | **2.2.2** |\n| Item 3 | 3.3.3 | 3.3.3 | 3.3.3 | 3.3.3 | **3.3.3** |\n| Item 4 | 4.4.4 | 4.4.4 | 4.4.4 | 4.4.4 | **4.4.4** |\n"

It feels like some kind of automatic escaping is happening somewhere.

Does anyone know how I can achieve a new line in this scenario, please?

Your help is greatly appreciated.


Solution

  • You could use md file and pass it as parameter.

    text.md

    #Updated Employee List
     
    Here is the updated list of employees:
     
    | Employee ID | Name          | Department    |
    |-------------|---------------|---------------|
    | 001         | John Smith    | HR            |
    | 002         | Jane Doe      | Engineering   |
    | 003         | Michael Brown | Marketing     |
    

    and then

    version=$(az devops wiki page show --org https://dev.azure.com/kmadej0455/ --project kmadej --path '/test' --wiki kmadej.wiki --query eTag -o tsv)
    
    az devops wiki page update --organization https://dev.azure.com/kmadej0455/ --project kmadej --wiki kmadej.wiki --version $version --path '/test'  --file-path text.md            --encoding utf-8