4

我有一个 bitbucket 存储库,它使用 bitbucket-pipelines 部署到 azure 上的本地存储库(用于我们的开发服务器)。我正在研究管道在部署到天蓝色之前将使用的构建步骤。我的构建步骤现在唯一要做的就是将构建文件输出到给定的 gitignored 目录中。然后它强制添加 gitignored 构建文件夹。然后它会修改触发管道的提交,最后强制将提交推送到 master。

所以我的文件看起来像这样

# bitbucket decided to make the repository shallow this line
# makes the repo unshallow so we can push later
- git fetch  https://<bitbucket-repo> --unshallow
# doing some setup so we can run the build scripts
- npm install
- npm install -g gulp
# just building files for now we can add tests in later
- npm run build:single
# forcing the build files to be included in the commit
# so that azure has access to the files.
- git add --force public/build/ 
# do some git configuration so it will let us commit
- git config --global user.email $GIT_USER_EMAIL
- git config --global user.name "\$GIT_USER_NAME"
# add to the last commit so we can keep its message
# this is so we can see the last commit message that was
# done on azure without creating a new commit message
# this command edits the previous commit and should
# never be done when that commit has already been 
# pushed to your target branch and if your target branch is
# public.
- git commit --amend --no-edit
# the below line pushes to a branch on azure we setup as a local branch
- git push --force https://<azure-branch-repo> master

我的问题是:

我会用这个 git 工作流程破坏任何东西吗?你有什么建议吗?

我想只有我的管道脚本才会推送到 azure 的本地仓库,所以可以修改提交,否则如果其他人推送到它,这可能是个坏主意。这是我应该关心的事情吗?我想保留原始提交消息,因为 azure 将其显示在以前的部署列表中。如果他们都有与他们的 bitbucket 提交相关的部署名称,那么返回到某个部署会变得更加简单。

我也想知道这是否是一个可以使用的好时机,git push --force因为我听说--force国旗被认为是危险的。由于我为每个部署将构建文件提交到 git,我将有一个偏离 repo 的提交,其中包含所有构建文件。我的想法是使用--force会忘记最后一次杂散提交,并按照 bitbucket-pipelines 构建它的方式拥有一切。我不确定我的解释--force push是否正确。

4

1 回答 1

6

您应该注意,这是针对我的开发服务器的。它设置为自动化,因此在开发过程中不那么麻烦,但在部署到生产过程中,我们手动复制文件

即便如此,Git 也不是为部署或存储可以生成的构建工件而设计的。
我在“分离开发和部署 git 存储库”中提出的建议是将您的工件(构建文件夹中的二进制文件)发布到工件存储库

它不一定是 Nexus:请参阅“构建 Java 应用程序并将其部署到 Azure Web 应用程序”,它使用 FTP(取自 Azure 门户上的 Azure Web 应用程序要点页面

于 2017-06-19T21:18:37.787 回答