This message was deleted.
# general
b
This message was deleted.
m
Hey @victorious-jordan-10935 👋
there isn’t a way to use use
--path
and
--config-file
in the same command, however what I think you’re looking for is the
--compare-to
flag built into diff
v
I am already using the compare-to flag, I am using the bitbucket pipeline example.
m
ok so I’m getting a bit confused then, what is the problem you’re running into
v
Copy code
- |
            infracost breakdown --path=/tmp/base \
                                --format=json \
                                --out-file=infracost-base.json
          - |
            infracost diff --config-file=infracost.yml \
                           --compare-to=infracost-base.json \
                           --format=json \
                           --out-file=infracost.json
m
ok
so you want to modify this as such:
v
So, to scan all my tf files, I need to pass a config-file for infracost, because on the current folder structure, a -
-path=./
is not able to read all my files
m
Copy code
- |
            infracost breakdown --config-file=/tmp/base/infracost.yml \
                                --format=json \
                                --out-file=infracost-base.json
          - |
            infracost diff --config-file=infracost.yml \
                           --compare-to=infracost-base.json \
                           --format=json \
                           --out-file=infracost.json
v
hmmm
tks so much, I did not thought this would work
I’ll try it here
m
👍
ooh actually one sec
i’ve made a mistake with that
let me post the full thing properly
v
ok
m
Copy code
pipelines:
  pull-requests:
    '**':
      - step:
          name: Run infracost
          image: infracost/infracost:ci-0.10
          script:
            # Clone the base branch of the pull request (e.g. main/master) into a temp directory.
            - git clone $BITBUCKET_GIT_HTTP_ORIGIN --branch=$BITBUCKET_PR_DESTINATION_BRANCH --single-branch /tmp/base
            - |
              cd /tmp/base
              infracost breakdown --config-file=$BITBUCKET_CLONE_DIR/infracost.yml
                                  --format=json \
                                  --out-file=infracost-base.json

            - |
              cd $BITBUCKET_CLONE_DIR
              infracost diff --config-file=infracost.yml
                            --compare-to=/tmp/base/infracost-base.json \
                            --format=json \
                            --out-file=infracost.json
            - |
              infracost comment bitbucket --path=infracost.json \
                                          --repo=$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG \
                                          --pull-request=$BITBUCKET_PR_ID \
                                          --bitbucket-token=myusername:$BITBUCKET_TOKEN \
                                          --behavior=update
I believe something like this should work
I’m not super familiar with bitbucket pipeline
but note the
BITBUCKET_CLONE_DIR
is the what I think they provide you as the original working directory
v
hmmm, make sense
I’ll try it here
m
cool beans, I’ll be here if you run into errors - which I’m assuming you will!
v
Maybe it worked, but I am validating
🙌 1
Because the comment is too big, 6K>lines
I would like to have a shorter comment only with the diff table…
m
yup
v
maybe if I change the diff command to use the --format-bitbucket-comment ????
m
yeah so you could do that and then you’d have to manually POST the bitbucket comment to your PR
this way you could trim the
output
section
v
if I use --format=bitbucket-comment, the infracost comment bitbucket would not work as it is?
m
sadly not -
infracost comment
is a helper to take our JSON output and POST it to the bitbucket API.
--format-bitbucket-comment
outputs a markdown comment which you could send to the API using
curl
or similar
unfortunately bitbucket comment doesn’t support the same level of html that other CI systems do, normally the
output
section is collapsible
v
do you have an example using output that is cleaner?
even if use the --format=bitbucket-comment and curl it using the API the output would not be collapsible?
m
Sadly not bitbucket ci doesn’t support the
details
html element in PR comments. Which is what we use to make it collapsible on other platforms.
I don’t have an example of an output format that is cleaner than what we have, unfortunately. If you’re just looking for the table then
--format=bitbucket-comment
will produce a simple markdown format and remove any lines below the
Copy code
**Infracost output:**
section using something like
sed
v
Ok Hugo, no problem
We are aiming to change into github in the future
m
👍
v
Thanks so much for the help, you are amazing ❤️
m
no problemo
w
@victorious-jordan-10935 I’ll DM you some bash I wrote that might help you just get the bitbucket summary table