【问题标题】:Get changes from local branch to current branch in CodeBuild?在 CodeBuild 中获取从本地分支到当前分支的更改?
【发布时间】:2020-01-30 04:27:54
【问题描述】:

我在 CodeBuild 中有一个构建规范,它使用 CodeBuild 中的 Source 中引用的源从不同的存储库下载 2 个分支(develop 和 refactored_branch)。我有一个脚本,通过将开发分支中的一些文件复制到 refactored_branch 来进行一些更改。当我完成文件的复制时,我想将所有这些更改从 refactored_branch 复制到另一个已经存在的分支 (branch_to_be_pushed),该分支与 refactored_branch 位于同一个仓库中,并将 branch_to_be_pushed 推送到 github?我尝试了 git checkout branch_to_be_pushed 然后 git pull refactored branch 甚至 git merge refactored_branch 但没有运气。构建规范看起来像这样:

pre_build:
    commands:
    - cd $CODEBUILD_SRC_DIR
    - pwd
    - git checkout develop
    - cd $CODEBUILD_SRC_DIR_Source2
    - pwd
    - git checkout refactored_branch
    - git config --global user.email $User    
    commands:
       - ./bin/deploy.py -src1=$CODEBUILD_SRC_DIR -src2=$CODEBUILD_SRC_DIR_Source2
  post_build:
    commands:
      - cd $CODEBUILD_SRC_DIR_Source2
      - pwd
      - ls -la
      - git status
      - git branch
      - git checkout branch_to_be_pushed
      - git status
      - git branch
      - git add .
      - git commit -m "push changes"
      - pwd
      - ls -la
      - git push https://$User:$Pass@github.com/xxxxxx/xxxxx-xxxxxx-xxxx.git

【问题讨论】:

  • 请提供构建日志,以便我们知道哪个命令因什么错误而失败。它与git凭据有关吗?你的建筑挂了吗?您在 BuildSpec 文件中使用的版本是什么(0.1 还是 0.2?)。

标签: git amazon-web-services aws-codebuild


【解决方案1】:

将 branch_to_be_pushed 推送到 github

只需添加你要推送的本地分支名称,如seen here:

git push https://$User:$Pass@github.com/xxxxxx/xxxxx-xxxxxx-xxxx.git branch_to_be_pushed

您可能希望使用 PAT (Personal Access Token) 而不是您的帐户密码,或基于专用密钥的 SSH URL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-09
    • 2011-07-17
    • 1970-01-01
    • 2023-03-09
    • 2013-12-09
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多