Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use the new report functionality?

Sébastien Gachoud August 23, 2024

Hi,

 

I am trying to use the new report functionality but I do not understand why it does not show up.

 

What I did:

In the pipeline, I ran 

 

curl --request PUT 'https://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/commit/$BITBUCKET_COMMIT/reports/mySystem-001' \ --header 'Content-Type: application/json' \ --data-raw '{ "title": "Security scan report", "details": "This pull request introduces 10 new dependency vulnerabilities.", "report_type": "SECURITY", "reporter": "mySystem", "link": "http://www.mySystem.com/reports/001", "result": "FAILED", "data": [ { "title": "Duration (seconds)", "type": "DURATION", "value": 14 }, { "title": "Safe to merge?", "type": "BOOLEAN", "value": false } ] }'

it ran just fine when I used the pipeline on the pull-request branch.

 

What I was expecting:

Something to appear in the report section of the pull request.

 

Can someone tell me what is not working here?

 

Edit: Actually I noticed afterward that the response to curl PUT does not trigger a failure to the pipeline. I receive a "Resource not found" error message but I am unable to find out why.

 

Best

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 27, 2024

Hey @Sébastien Gachoud ,

welcome to the Atlassian Community!

Looking at the request you shared, it seems you're not adding credentials for authentication, and thus the API is returning a 'Resource not found' error.

I was able to successfully create a report using the example request below : 


curl --location -u USERNAME:APP_PASSWORD --request PUT
'https://api.bitbucket.org/2.0/repositories/test-workspace-4/test_zip_file/commit/401321e808c0e06af7cdf954319f0c66e719e35b/reports/mysystem-001' \
--header
'Content-Type: application/json' \
--data-raw '{
"title": "Security scan report",
"details": "This pull request introduces 10 new dependency vulnerabilities.",
"report_type": "SECURITY",
"reporter": "mySystem",
"link": "http://www.mySystem.com/reports/001",
"result": "FAILED",
"data": [
{
"title": "Duration (seconds)",
"type": "DURATION",
"value": 14
},
{
"title": "Safe to merge?",
"type": "BOOLEAN",
"value": false
}
]
}'

Where:

  • USERNAME : your bitbucket account username. You can find/change the username under your personal bitbucket settings.
  • APP PASSWORD: a token used for authentication. If you haven't already, you can create a new app password with at least repository:read scope, that is required for that endpoint.

Could you adjust your request as per the example above and let us know how it goes?

Also, I would suggest to test the request locally on your terminal first to confirm it's working and make any necessary adjustments, and once it's working locally, you can update your pipeline to match.

I hope that helps! Let us know in case you have any questions.

Thank you, @Sébastien Gachoud !

Patrik S

Sébastien Gachoud August 28, 2024

Hello,

 

Thank you for your help. I am actually using the proxy:

 

curl --proxy 'http://localhost:29418--request PUT 'http://api.bitbucket.org/2.0/repositories/$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG/commit/$BITBUCKET_COMMIT/reports/mySystem-001' \ --header 'Content-Type: application/json' \ --data-raw '{ "title": "Security scan report", "details": "This pull request introduces 10 new dependency vulnerabilities.", "report_type": "SECURITY", "reporter": "mySystem", "link": "http://www.mySystem.com/reports/001", "result": "FAILED", "data": [ { "title": "Duration (seconds)", "type": "DURATION", "value": 14 }, { "title": "Safe to merge?", "type": "BOOLEAN", "value": false } ] }'

Best

Sébastien Gachoud September 24, 2024

Hi,

 

Would you have some other idea?

 

Best

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events