https://infracost.io logo
#help
Title
# help
m

magnificent-helmet-77737

05/31/2023, 3:36 PM
Hi, I've setup the Infracost in my Azure DevOPs CI/CD pipeline and am getting this error when teh pipeline runs? /home/vsts/work/_temp/ccc1bba2-726b-4a9c-9d66-381e57c32bfc.sh: line 1: System.PullRequest.TargetBranch: command not found Cloning into '/tmp/base'... fatal: could not read Password for 'https://Kainos-ALZ@dev.azure.com': terminal prompts disabled ##[debug]Exit code 128 received from tool '/usr/bin/bash' ##[debug]STDIO streams have closed for tool '/usr/bin/bash' ##[error]Bash exited with code '128'. ##[debug]Processed: ##vso[task.issue type=error;]Bash exited with code '128'. ##[debug]task result: Failed ##[debug]Processed: ##vso[task.complete result=Failed;done=true;] Finishing: Checkout base branch
b

busy-agent-35515

05/31/2023, 3:51 PM
Hello!
m

magnificent-helmet-77737

05/31/2023, 3:53 PM
hi
b

busy-agent-35515

05/31/2023, 3:55 PM
Have you been using our example pipeline yaml?
m

magnificent-helmet-77737

05/31/2023, 3:59 PM
yes
b

busy-agent-35515

05/31/2023, 4:00 PM
I haven't seen this error before, I suspect you have a private repo and the pipeline can't access it. Could you please try adding
--config http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)"
to the
Checkout base branch
step and retry?
It would look like
git clone $(Build.Repository.Uri) --branch=${branch} --single-branch /tmp/base --config http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)"
m

magnificent-helmet-77737

05/31/2023, 4:01 PM
ah yes its a private repo and we are using ubuntu selfhosted agaents
now getting Cloning into '/tmp/base'... warning: Could not find remote branch to clone. fatal: Remote branch not found in upstream origin ##[error]Bash exited with code '128'. #
b

busy-agent-35515

05/31/2023, 4:14 PM
That's progress 🙂 Now we have access, but something's wrong with the branch name
m

magnificent-helmet-77737

05/31/2023, 4:14 PM
ok, branch is Main
b

busy-agent-35515

05/31/2023, 4:15 PM
We tried to derive the name from the pull request:
Copy code
branch=$(System.PullRequest.TargetBranch)
branch=${branch#refs/heads/}
You can add
echo ${branch}
to the step and see what it outputs
Or, just for the sake of test, you can just hardcode it for now
m

magnificent-helmet-77737

05/31/2023, 4:17 PM
just testing with a new PR
appears to be working now
qq, if using modules does th epipeline scan all folders within teh root terraform folder specified in path?
b

busy-agent-35515

05/31/2023, 4:41 PM
Yes
m

magnificent-helmet-77737

05/31/2023, 4:41 PM
great thanks
b

busy-agent-35515

05/31/2023, 4:41 PM
If your modules are also private, an additional setup is needed. Our example describes it in its comments
m

magnificent-helmet-77737

05/31/2023, 4:42 PM
oh ok, yes whole repo is private therefore all modules are as well
b

busy-agent-35515

05/31/2023, 4:42 PM
Ah, alright. If they are part of the repo, then no actions are needed. I thought about the modules stored in different repos 🙂
106 Views