Hey folks. IDK if this is the right place, but I a...
# general
v
Hey folks. IDK if this is the right place, but I am facing an issue related to integrating Infracost into my CI/CD Pipelines on Bitbucket. I am receiving an error related to:
Copy code
Error: Error creating comment: 401 Unauthorized
I’ve searched on github issues, but only found some information related to emojis comments that seems to be fixed already. My token has full access scope. Do you have any hints on that? Regards…
b
Hi Pietro! 👋 Let's see...
Do you use Bitbucket Cloud or Server version?
v
Bitbucket Cloud
👍 1
b
May I also ask if you can copy/paste the
infracost comment
command you used (removing the sensitive info)?
v
Copy code
infracost comment bitbucket --path=infracost.json \     
--repo=$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG \
--pull-request=$BITBUCKET_PR_ID \                                        --bitbucket-token=$BITBUCKET_TOKEN \                                       --behavior=update
Already teste with --behaviour=new/delete-and-new/update
b
Could you try to change
--bitbucket-token
value to
<your username>:$BITBUCKET_TOKEN
? BB Cloud needs this format for some reason
I guess we need to update our docs to use this format, we only mention this detail in the flag description https://www.infracost.io/docs/features/cli_commands/#bitbucket
v
--bitbucket-token=pietro.dellamore:TOKEN
like this?
b
Yep
The reason why it needs to be done this way is that we use their API to post comments and apparently their API uses basic auth in format "username:password", where token is the password in this case https://developer.atlassian.com/cloud/bitbucket/rest/intro/?utm_source=%2Fbitbucket%2Fapi%2F2%2Freference%2Fmeta%2Fauthentication&amp;utm_medium=302#authentication
Any luck?
v
Not yet :c
😕 1
b
Still 401?
v
Yes, but I feel that I am doing something wrong
IDK if this is because we use Okta as IdP for Bitbucket…
Maybe this have a relation
b
Hm, how have you generated the token?
v
Using app passwords on bitbucket cloud
b
Yeah, I used the same 🤔
v
I believe that my username is my e-mail address
I saw somewhere, that this might be a problem, I just don’t remember where I saw it
b
Can you try with email maybe? :)
w
There’s a curl to test the bitbucket authentication if that helps: https://github.com/infracost/infracost/issues/1693
v
I’ll try later and update it here
👍 1
Thanks so much until now for all the effort
👍 2
b
Good luck, hope it works 🙂
Hi Pietro! Just checking in if you had a chance to try it
v
Hi @busy-agent-35515 sorry for the delayed response, it was holiday here in Brazil.
It does work with username:token! Thank you so much for the effort and support ❤️
infraheart 2
b
Hey! No worries! Hope you had a great time :)
Glad to hear it! :)
w
@busy-agent-35515 Should I update the bitbucket pipeline readme to mention this? I can also add a troubleshooting section to that with the 401 error (similar to what we do for gitlab). Any other action items for me?
b
@white-airport-8778 We mentioned in CLI commands section in our docs, but yeah, would be great to have it there https://www.infracost.io/docs/features/cli_commands/#bitbucket. Thank you!
w
thanks - will do!
🙌 1
v
I tried to open a PR adding this on the README.md but I do not have enough permissions to do it… :c
w
That would be much appreciated! ah you should be able to fork the repo, then send a PR from your fork to our repo. I’ll try and get to this later this week if you’re busy though
I am running out of time now, if you have too many changes to request, I can do it later. Tks
w
Thank you! I merged it as it’s better than what we have and helps other users 🙂 Later this week I’ll tidy-up and add a troubleshooting section like we have for gitlab
v
Nice! ❤️