admin管理员组文章数量:1312735
I have this task that is supposed to add file contents to the PR comment:
- task: GitHubComment@0
inputs:
gitHubConnection: 'Github PR comment'
repositoryName: 'myrepo/'
comment: |
Validation Failed
<details>
<summary>Report Details</summary>
```xml
$(XML_REPORT)
```
</details>
condition: eq(variables['addGithubComment'], 'true')
displayName: 'Update github comment'
However, GitHub doesn't seem to add all the contents on the PR comment.
I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
I have this task that is supposed to add file contents to the PR comment:
- task: GitHubComment@0
inputs:
gitHubConnection: 'Github PR comment'
repositoryName: 'myrepo/'
comment: |
Validation Failed
<details>
<summary>Report Details</summary>
```xml
$(XML_REPORT)
```
</details>
condition: eq(variables['addGithubComment'], 'true')
displayName: 'Update github comment'
However, GitHub doesn't seem to add all the contents on the PR comment.
I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
Share Improve this question edited Jan 31 at 18:51 bryanbcook 18.4k2 gold badges47 silver badges79 bronze badges asked Jan 31 at 16:10 peepoCodepeepoCode 334 bronze badges 2- "I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text." - according to the documentation of the task, that doesn't seem possible. – Rui Jarimba Commented Feb 1 at 8:55
- @peepoCode, it's not supported to attach the file directly to comment via DevOps task, even not via github rest api/command, since it requires the file is accessible by Github, i shared the details below, please let me know if you have any queries, thanks. – wade zhou - MSFT Commented Feb 17 at 1:22
1 Answer
Reset to default 0I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
I can reproduce the same with you with the task, currently it's not supported to attach the file directly to comment.
Directly checked on github, when you upload a file to a GitHub pull request comment, GitHub generates a unique URL for that file as below:
But there isn't a direct command or script to upload a file and get a similar link without using the GitHub web interface.
As an alternative, you can use the github repo file link instead(you can upload the file to github in previous step), so that the file is accessible in the comment.
Put the github file link in the format like [customlog.txt](https://github/test/temp1/blob/dev1/test.log)
- task: GitHubComment@0
inputs:
gitHubConnection: 'githubtemp'
repositoryName: 'test/temp1'
id: '2'
comment: "[customlog.txt](https://github/test/temp1/blob/dev1/test.log)"
It's same behavior with bash command:
- bash: |
curl -X POST -H "Authorization: token $(githubtoken)" -H "Content-Type: application/json" -d '{"body": "[customlog.txt](https://github/test/temp1/blob/dev1/test.log)"}' https://api.github/repos/test/temp1/issues/2/comments
本文标签: githubAttach file on PR comment in Azure devops ymlStack Overflow
版权声明:本文标题:github - Attach file on PR comment in Azure devops yml - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741907561a2404238.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论