Here is the template I used in the pipeline to create a GitHub Enterprise release.
I found code 401 means "unauthorized", but I don't know what's wrong with my setup, Is there any way to get the detailed cause of code 401?
- template: steps/git/github-create-release.yaml@templates
parameters:
githubRepo: client/SysInfo
githubUrl: github.azc.ext.xx.com
githubUser: winiotapp
githubToken: $GithubToken
assets: $BUILD_ARTIFACTSTAGINGDIRECTORY\\*.msi
body: "System Information Release"
draft: true
name: "System Information"
tagName: "1.0"
Here is the error message returned by template:
Creating a release at github.azc.ext.xx.com/api/v3/repos/client/SysInfo/releases with tagName [1.0] and name [System Information].
Here is the API call in the template that returned status code 401:
RESPONSE=$(curl -u ${{ parameters.githubUser }}:${{ parameters.githubToken }} \
--location --request POST ${{ parameters.githubUrl }}/api/v3/repos/${{ parameters.githubRepo }}/releases \
--header "Content-Type: application/json" \
--data "$(release_parameters)" \
-s -w "%{http_code}")
STATUS=$(tail -n1 <<< "$RESPONSE")
"winiotapp" is my GitHub enterprise user name and is the admin of repository client/SysInfo.
Here is the $GithubToken I generated.
The main issue is caused by variable syntax in your yaml.
Please refer to my sample below for your reference, it works on my side. i have only github on hand, please change the url related if needed for github enterprise.
Main yaml:
The template yaml, i echo the value for checking, you can remove the echo strings if needed.
You need to specify the real msi file name in yaml, not
*.msi
. If you would like to release all msi files, you can put them in a folder and zip it in task, transfer the zip file as parameter instead.