AWS Codepipeline 是否会将符号链接传递到工件中的 Codebuild

问题描述 投票:0回答:4

我的 github 存储库中有一些符号链接。

当我有一个直接从 github 克隆的 Codebuild 项目时,符号链接会被保留。

我进行了切换,以便 Codepipeline 侦听 github 中我的

dev
分支中的更改,并将工件传递给 codebuild。

自从进行此切换后,Codebuild 就再也看不到符号链接了。

这是设计使然,还是我可能在配置代码管道时遗漏了某些内容?

amazon-web-services github aws-codepipeline aws-codebuild
4个回答
11
投票

我在部署节点 Elastic Beanstalk 应用程序时遇到符号链接问题。看起来工件现在支持符号链接。 查看文档

artifacts:
  enable-symlinks: yes

将此添加到

buildspec.yml
文件解决了我的问题


5
投票

到目前为止,AWS CodePipeline 不支持源中的符号链接。请参阅讨论论坛中的源工件无法正确处理符号链接或文件模式,我们可以看到

我们已经有了一个管道设置,其初始“源”阶段来自 GitHub 上的私人存储库。存储库内容被压缩并最终成为管道的第一个输入工件。

我注意到 zip 工件存在一些问题:

1.) 符号链接不是作为正确的符号链接出现的,而是作为文本文件出现的,其内容是符号链接指向的位置。

也许 AWS CodePipeline 团队将来会修复它。


2
投票

对于再次访问此站点的任何人,现在有一种方法可以做到这一点。您需要在源操作上使用 github 连接器 v2,然后选择“git 克隆模式”。 这将使 codebuild 直接克隆您的存储库,而不是通过工件传递。

您还需要添加以下权限

管道角色:

  • codestar-connections:UseConnection。

代码构建角色:

  • codestar-连接:UseConnection
  • 代码提交:GitPull

0
投票

要向其他答案添加详细信息,如果您想要的只是带有符号链接的工作

git pull
,则需要使用
CODEBUILD_CLONE_REF
更新 CodePipeline,指向 CodeBuild。

下面是简化的地形示例。


代码管道:

resource "aws_codepipeline" "this" {
  name     = "${var.name}-${var.environment}"
  role_arn = aws_iam_role.codepipeline.arn

  artifact_store {
    type     = "S3"
    location = aws_s3_bucket.codepipeline.bucket
  }

  stage {
    name = "Pull-Source"
    action {
      category         = "Source"
      namespace        = "SourceVariables"
      name             = "${aws_codestarconnections_connection.repo.provider_type}-Pull-${var.repo_branch_name}"
      owner            = "AWS"
      provider         = "CodeStarSourceConnection"
      version          = "1"
      output_artifacts = [local.repo_pull_artifact]

      configuration = {
        ConnectionArn        = "${aws_codestarconnections_connection.repo.arn}"
        FullRepositoryId     = var.repo_name
        BranchName           = var.repo_branch_name
        OutputArtifactFormat = "CODEBUILD_CLONE_REF"
      }
    }
  }

  stage {
    name = "Clone-Repo"
    action {
      category         = "Build"
      name             = "Clone-GitHub-Repo"
      owner            = "AWS"
      provider         = "CodeBuild"
      input_artifacts  = [local.repo_pull_artifact]
      output_artifacts = [local.repo_clone_artifact]
      version          = "1"

      configuration = {
        ProjectName   = var.github_clone_codebuild_arn
        PrimarySource = local.repo_pull_artifact
      }
    }
  }
}

代码构建

resource "aws_codebuild_project" "github_clone" {
  name          = "${var.name}-github-clone-${var.environment}"
  description   = "Clone GitHub Repo"
  service_role  = aws_iam_role.codebuild_github_clone.arn
  build_timeout = var.build_timeout_minutes

  source {
    type      = "CODEPIPELINE"
    buildspec = "./buildspec.yml"
  }

  artifacts {
    type = "CODEPIPELINE"
  }

  environment {
    compute_type    = "BUILD_GENERAL1_SMALL"
    image           = "public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:5.0"
    type            = "LINUX_CONTAINER"
  }
}

代码构建

buildspec.yml

version: 0.2
env:
  git-credential-helper: yes
artifacts:
  files:
    - "**/*"
  enable-symlinks: yes
© www.soinside.com 2019 - 2024. All rights reserved.