plugins/aws_ecr/lib/samson_aws_ecr/samson_plugin.rb
def ensure_repositories(build)
        DockerRegistry.all.each do |registry|
          next unless client = ecr_client(registry)
          name = build.project.docker_repo(registry, build.dockerfile).split('/', 2).last

          begin
            begin
              client.describe_repositories(repository_names: [name])
            rescue Aws::ECR::Errors::RepositoryNotFoundException
              client.create_repository(repository_name: name)
            end
          rescue Aws::ECR::Errors::AccessDenied
            Rails.logger.info("Not allowed to create or describe repositories")
          end
        end
      end
# we make sure the repo exists so pushes do not fail
# - ignores if the repo already exists
# - ignores if the repo cannot be created due to permission problems
we make sure the repo exists so pushes do not fail
ignores if the repo already exists
ignores if the repo cannot be created due to permission problems
we make sure the repo exists so pushes do not fail ignores if the repo already exists ignores if the repo cannot be created due to permission problems
def ensure_repositories(build)
        DockerRegistry.all.each do |registry|
          next unless client = ecr_client(registry)
          name = build.project.docker_repo(registry, build.dockerfile).split('/', 2).last
          begin
            begin
              client.describe_repositories(repository_names: [name])
            rescue Aws::ECR::Errors::RepositoryNotFoundException
              client.create_repository(repository_name: name)
            end
          rescue Aws::ECR::Errors::AccessDenied
            Rails.logger.info("Not allowed to create or describe repositories")
          end
        end
      end
def ensure_repositories ( build ) DockerRegistry . all . each do | registry | next unless client = ecr_client ( registry ) name = build . project . docker_repo ( registry , build . dockerfile ) . split ( '/' , 2 ) . last begin begin client . describe_repositories ( repository_names : [ name ] ) rescue Aws :: ECR :: Errors :: RepositoryNotFoundException client . create_repository ( repository_name : name ) end rescue Aws :: ECR :: Errors :: AccessDenied Rails . logger . info ( "Not allowed to create or describe repositories" ) end end end
we make sure the repo exists so pushes do not fail
 ignores if the repo already exists
 ignores if the repo cannot be created due to permission problems
we make sure the repo exists so pushes do not fail ignores if the repo already exists ignores if the repo cannot be created due to permission problems
build