<!here> I am getting below error when I tried to d...
# help
m
<!here> I am getting below error when I tried to do bitbuket comment in azure pipeline. I have output for making sure whether its correct value in my pipeline as well. Can anyone help.
Copy code
Error: invalid argument "23" for "--pull-request" flag: must be integer
pipeline value;
Copy code
###############################
23
################################
b
Hello! Could you please clarify how you pass the argument? Does it come from an env var?
Also, could you please post the full comment command
m
command:
Copy code
infracost comment bitbucket --path=/tmp/infracost.json \
        --repo=test/test  \
        --pull-request=$(prno) \
        --bitbucket-token=user:$(BitbucketToken) \
        --behavior=update
env:
Copy code
- pwsh: |
      'Write-Host "##vso[task.setvariable variable=prno]$(System.PullRequest.PullRequestNumber)"'
b
Could you please try
--pull-request=$(System.PullRequest.PullRequestId)
directly?
m
thats the tricky part. We are using azure templates and predefined variable dont work here. Thats why I am writing the value to a variable and then passing it to infra command. More info: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&amp;tabs=yaml
I tried with commit and as its output will be string. But got the below error.
Copy code
2024-04-15T14:40:07Z INF Finding matching comments for tag generated by Infracost
Error: The pull request comment was generated successfully but could not be posted:
Error getting comments: 500 Internal Server Error
b
Hey, sorry for late reply. Our team has an in-person week, so it's a bit busy here 🙂 Could you please try
Copy code
"##vso[task.setvariable variable=prno]$(System.PullRequest.PullRequestId)"
instead of
PullRequestNumber
. I have low hopes on this, but worth a try. It's a really strange error. The only way I was able to reproduce it is by adding spaces in front of the value:
--pull-request=    23
. I'm not very familiar with Azure Devops. Is it possible to use a trim function or something to modify the value here? The 500 error comes from your Bitbucket server API when CLI tries to fetch the PR comments. Are you able to get the API logs to see why it fails?
m
when i use commit, i am getting 500 and I tried with from my terminal its getting 200 response
b
Oh, that's interesting. Was it the same exact commit SHA?
The code of the
comment
command is the same in both cases (meaning the same API request is going out to the server), but we don't control how the server treats the provided values. It's a guess, but maybe it doesn't like the strings too?
m
No worries. Am able to solve round the neck. I converted the string to int and now its working fine. thanks for all your help
b
Awesome job! Great you were able to resolve this 👍