sam build using docker image fails when .git is included.

0

Detail

I used "sam init" to create a hello-world (docker image). Then I tried "sam build" and it completed successfully.

Then I connected git (code-commit) and ran "sam build" again and it failed. (At this point, the Image is created, but if I ran "sam deploy" it failed.)

Same with using the option "--no-cached".

Then I deleted ".git" and ran "sam build" again and it worked. ("sam deploy" also works fine.)

Is this a bug? Or is the specification that git cannot be used with sam?

Environment

  • Windows10 (64bit)
  • Python 3.9
  • sam hello-world (Node16, Image)
  • PowerShell / cmd.exe
  • Docker Desktop (WSL2)

Dir and files

<project dir> * .git * events * hello-world * .gitignore * README.md * template.yaml

Error message

︙
Build Succeeded

Built Artifacts  : .aws-sam\build
Built Template   : .aws-sam\build\template.yaml

Commands you can use next
=========================
[*] Validate SAM template: sam validate
[*] Invoke Function: sam local invoke
[*] Test Function in the Cloud: sam sync --stack-name {stack-name} --watch
[*] Deploy: sam deploy --guided

Traceback (most recent call last):
  File "runpy.py", line 194, in _run_module_as_main
  File "runpy.py", line 87, in _run_code
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\__main__.py", line 12, in <module>
    cli(prog_name="sam")
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 166, in wrapped
    metric_specific_attributes["gitOrigin"] = get_git_remote_origin_url()
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\project_metadata.py", line 34, in get_git_remote_origin_url
    metadata = _parse_remote_origin_url(str(runcmd.stdout))
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\project_metadata.py", line 104, in _parse_remote_origin_url
    return [str(item) for item in pattern.findall(url)[0]]
IndexError: list index out of range
1 Answer
0
Accepted Answer

I solved it by upgrading sam.

sizu
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions