Closed anirudhbagri closed 4 years ago
When using Bitbucket Server?
Have you tried passing the -comment-template
parameter and surrounding message with ``` before and after ?
The template is documented here: https://github.com/tomasbjerre/violation-comments-lib
Yes, bitbucket server.
I am have tried using
-comment-template "```{{violation.message}}```"
and
-comment-template "{{violation.message}}"
both didn't work.
Turns out this is a feature in Mustache. You can use tripple {{{
and }}}
to avoid escaping:
npx violation-comments-to-bitbucket-server-command-line \
-server-url http://localhost:7990 \
-username admin \
-password admin \
-pk PROJ \
-rs REPO \
-prid 1 \
-keep-old-comments true \
-create-single-file-comments false \
-create-comment-with-all-single-file-comments true \
-comment-only-changed-files false \
-v "GENERIC" "." ".*eneric\.txt$" "Generic" \
-comment-template "
message: {{{violation.message}}}
"
This did partially what I expected.
-comment-template "message: {{{violation.message}}}"
BUT, My file is having lines with multiple spaces in a single line.. like this:
Name Stmts Miss Cover
------------------------------------------------------------------
file1 0 0 100%
path/to/file2 0 0 100%
a/long/file/path/herefile3 47 5 89%
------------------------------------------------------------------
TOTAL 100 8 92%
But, the comment that is posted, has all the white space and line with ----
removed.
This is that I get as comment.
Name Stmts Miss Cover
file1 0 0 100%
path/to/file2 0 0 100%
a/long/file/path/herefile3 47 5 89%
TOTAL 100 8 92%
I created such a file:
Name Stmts Miss Cover
------------------------------------------------------------------
file1 0 0 100%
path/to/file2 0 0 100%
a/long/file/path/herefile3 47 5 89%
------------------------------------------------------------------
TOTAL 100 8 92%
here: https://github.com/tomasbjerre/violations-test/blob/feature/addingcrap/generic.txt
Reported with
npx violation-comments-to-bitbucket-server-command-line \
-server-url http://localhost:7990 \
-username admin \
-password admin \
-pk PROJ \
-rs REPO \
-prid 1 \
-keep-old-comments false \
-create-single-file-comments false \
-create-comment-with-all-single-file-comments true \
-comment-only-changed-files false \
-v "GENERIC" "." ".*eneric\.txt$" "Generic" \
-comment-template "
message:
\\\`\\\`\\\`
{{{violation.message}}}
\\\`\\\`\\\`
"
And I get:
This is not working for me :( Instead, it printed like this
message:
`
Name Stmts Miss Cover
........
TOTAL 100 8 92%
`
BTW, I am pushing this from Jenkins Job script.
This is the exact command:
echo "Posting Test Coverage Report"
java -jar violation.jar \
-project-key $project_key \
-pull-request-id $pr_id \
-repo-slug $repo_slug \
-server-url $server \
-keep-old-comments false \
-create-single-file-comments false \
-create-comment-with-all-single-file-comments true \
-comment-only-changed-files false \
-keystore-path $path \
-keystore-pass $pass \
-v GENERIC "." ".*/coverage_report\.txt\$" "Code Coverage Reporter" \
-comment-template "
message:
\\\`\\\`\\\`
{{{violation.message}}}
\\\`\\\`\\\`"
echo "Finished Posting Test Coverage Report"
I see half of the content becoming bold?
This is the command I used:
Java -jar violation.jar \
-server-url $server \
-pk $proj \
-rs $repo \
-prid $pr \
-keep-old-comments false \
-create-single-file-comments false \
-create-comment-with-all-single-file-comments true \
-comment-only-changed-files false \
-v "GENERIC" "." ".*coverage_report\.txt$" "Generic" \
-keystore-path $PATH \
-keystore-pass $PASS \
-comment-template "
message:
\\\`\\\`\\\`
{{{violation.message}}}
\\\`\\\`\\\`
"
Strange... And if you manually edit the comment, is it still missing spaces?
Yes.
Managed to get it done using this:
Java -jar violation.jar \
-server-url $server \
-pk $proj \
-rs $repo \
-prid $pr \
-keep-old-comments false \
-create-single-file-comments false \
-create-comment-with-all-single-file-comments true \
-comment-only-changed-files false \
-v "GENERIC" "." ".*coverage_report\.txt$" "Generic" \
-keystore-path $PATH \
-keystore-pass $PASS \
-comment-template "
message:
~~~
{{{violation.message}}}
~~~
"
Thank you so much @tomasbjerre for helping me out.
Actual: The violation generated by GenericParser is a POST as a single line whatever might be the source. Excepted: The comments must be multi-lined if the source has them as multi-lined.