Just trying to install infracost in a bitbucket pi...
# general
Just trying to install infracost in a bitbucket pipeline, but I am getting an error when trying to clone the repo, has anyone done this successfully, I have an ssh key on the repo as its private and have the public key for that as an access key
Hi Paul, what error are you seeing? And do you have an example of the pipeline you have?
The error is
+ git clone $BITBUCKET_GIT_HTTP_ORIGIN --branch=$BITBUCKET_PR_DESTINATION_BRANCH --single-branch /tmp/base
Cloning into '/tmp/base'...
fatal: could not read Username for '<https://bitbucket.org>': No such device or address
The pipeline is basically the one in the documentation
- step:
name: Run infracost
image: infracost/infracost:ci-0.10
- git clone $BITBUCKET_GIT_HTTP_ORIGIN --branch=$BITBUCKET_PR_DESTINATION_BRANCH --single-branch /tmp/base
#- |
#  mkdir -p ~/.ssh
`# eval `ssh-agent -s`` _`# echo "$GIT_SSH_KEY" | tr -d '\r' | ssh-add -`_ _`# ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts`_ `# Generate Infracost JSON file as the baseline, add any required sub-directories to path, e.g.
- _|_
infracost breakdown --path=/tmp/base/ \
--format=json \
# Generate an Infracost diff and save it to a JSON file.
- _|_
infracost diff --path=./ \
--compare-to=infracost-base.json \
--format=json \
# Posts a comment to the PR.
- _|_
INFRACOST_ENABLE_CLOUD=true infracost comment bitbucket --path=infracost.json \
--pull-request=$BITBUCKET_PR_ID \
--bitbucket-token=radiateb2b3:$BITBUCKET_TOKEN \
hmm, can you try it with
that did it great thanks
its just telling me my api key is wrong now so need to double check that
Awesome, thanks for reporting. I'll try it out with a few other things and see how we update the docs for it.
hi i found the issue with the API key, it is also a bug on the site
what it copies though is the key with this prepended
sorry to be a pain, now i get the following error running the step:
time="2022-08-26T09:21:30Z" level=info msg="Estimate uploaded to organization 'paul' in Infracost Cloud"
time="2022-08-26T09:21:30Z" level=info msg="Finding matching comments for tag generated by Infracost"
Error: The pull request comment was generated successfully but could not be posted:
Error getting comments: 401 Unauthorized
Looks like a token issue of some sort. Can you try the curl calls from the Troubleshooting section here: https://bitbucket.org/infracost/infracost-bitbucket-pipeline/src/master/
will do thanks
what it copies though is the key with this prepended
Ah interesting, yeah I think that’s so it works locally, but that doesn’t make sense for CI/CD. I’ll chat to the team and see if we want to change this.
Let me know how if the curls help with debugging the token issue
ok struggling a bit with the token, as far as i can tell you only get http access tokens for the server version of bitbucket not the cloud version
so i am not sure what to put in the mytoken bit
is it an app password?
ok that did it, so in cloud you need to create an app password and use that instead of
hope that helps
Ah yeah, in Bitbucket Cloud it has to be a user password or app password.
Is that working in the pipeline now as well?
it is thanks
i created a local repo variable and oput the app password in there
thanks for the help
For the
did you still have to prepend it with
yes so <username>:$APP_PASSWORD
Great thanks!