https://infracost.io logo
#general
Title
# general
v

victorious-jordan-10935

06/15/2022, 12:45 PM
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

busy-agent-35515

06/15/2022, 12:53 PM
Hi Pietro! 👋 Let's see...
Do you use Bitbucket Cloud or Server version?
v

victorious-jordan-10935

06/15/2022, 12:56 PM
Bitbucket Cloud
👍 1
b

busy-agent-35515

06/15/2022, 12:57 PM
May I also ask if you can copy/paste the
infracost comment
command you used (removing the sensitive info)?
v

victorious-jordan-10935

06/15/2022, 12:59 PM
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

busy-agent-35515

06/15/2022, 1:00 PM
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

victorious-jordan-10935

06/15/2022, 1:01 PM
--bitbucket-token=pietro.dellamore:TOKEN
like this?
b

busy-agent-35515

06/15/2022, 1:01 PM
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

victorious-jordan-10935

06/15/2022, 1:26 PM
Not yet :c
😕 1
b

busy-agent-35515

06/15/2022, 1:26 PM
Still 401?
v

victorious-jordan-10935

06/15/2022, 1:27 PM
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

busy-agent-35515

06/15/2022, 1:27 PM
Hm, how have you generated the token?
v

victorious-jordan-10935

06/15/2022, 1:28 PM
Using app passwords on bitbucket cloud
b

busy-agent-35515

06/15/2022, 1:29 PM
Yeah, I used the same 🤔
v

victorious-jordan-10935

06/15/2022, 1:31 PM
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

busy-agent-35515

06/15/2022, 1:32 PM
Can you try with email maybe? :)
w

white-airport-8778

06/15/2022, 1:40 PM
There’s a curl to test the bitbucket authentication if that helps: https://github.com/infracost/infracost/issues/1693
v

victorious-jordan-10935

06/15/2022, 1:49 PM
I’ll try later and update it here
👍 1
Thanks so much until now for all the effort
👍 2
b

busy-agent-35515

06/15/2022, 1:50 PM
Good luck, hope it works 🙂
Hi Pietro! Just checking in if you had a chance to try it
v

victorious-jordan-10935

06/20/2022, 5:22 PM
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

busy-agent-35515

06/20/2022, 5:22 PM
Hey! No worries! Hope you had a great time :)
Glad to hear it! :)
w

white-airport-8778

06/20/2022, 5:28 PM
@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

busy-agent-35515

06/20/2022, 5:30 PM
@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

white-airport-8778

06/20/2022, 5:31 PM
thanks - will do!
🙌 1
v

victorious-jordan-10935

06/20/2022, 5:33 PM
I tried to open a PR adding this on the README.md but I do not have enough permissions to do it… :c
w

white-airport-8778

06/20/2022, 5:36 PM
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

white-airport-8778

06/20/2022, 5:45 PM
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

victorious-jordan-10935

06/20/2022, 5:45 PM
Nice! ❤️
8 Views