Hi, I've setup the Infracost in my Azure DevOPs CI...
# help
m
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
Hello!
m
hi
b
Have you been using our example pipeline yaml?
m
yes
b
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
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
That's progress 🙂 Now we have access, but something's wrong with the branch name
m
ok, branch is Main
b
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
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
Yes
m
great thanks
b
If your modules are also private, an additional setup is needed. Our example describes it in its comments
m
oh ok, yes whole repo is private therefore all modules are as well
b
Ah, alright. If they are part of the repo, then no actions are needed. I thought about the modules stored in different repos 🙂
176 Views