我有一个bitbucket repo,它使用bitbucket-pipelines来部署到azure上的本地存储库(对于我们的开发服务器)。我正在研究管道在部署到azure之前将使用的构建步骤。我的构建步骤现在唯一能做的就是将构建的文件输出到给定的目录中,该目录是gitignored。然后强制添加gitignored构建文件夹。然后修改为触发管道的提交,最后强制将提交推送到master。
所以我的文件看起来像这样
UILabel.appearance().textColor = UIColor.red
我是否会使用此git工作流程打破任何问题?你有什么建议吗?
我认为只有我的管道脚本会推向azure的本地回购 所以修改提交是可以的,否则如果其他人推动它可能是一个坏主意。这是我应该关注的吗?我想保留原始提交消息,因为azure将其显示在先前部署的列表中。如果它们都具有与其bitbucket提交相关的部署名称,那么返回某个部署会更加简单。
我也想知道这是否可以使用# 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 push --force
标志被认为是危险的。由于我将构建文件提交给每个部署的git,因此我将提交一个提交文件,其中包含所有构建文件的repo。我的想法是使用--force
会忘记最后的迷失提交,并且只需要像bitbucket-pipelines一样构建它。我不确定我对--force
的解释是否正确。
答案 0 :(得分:6)
您应该注意这是我的开发服务器。它设置为自动化,因此在开发过程中不那么麻烦,但在部署到生产期间,我们手动复制文件
即使如此,Git也不是用于部署或存储可生成的构建工件 我在&#34; Separate development and deployment git repositories&#34;是将工件(构建文件夹中的二进制文件)发布到artifact repository。
它不一定是Nexus:请参阅&#34; Build and Deploy your Java app to an Azure web app&#34;,它使用FTP(取自Azure portail上的Azure网络应用程序基本页面)。