【问题标题】:dotnet publish with gitlab-ci for dummiesdotnet 使用 gitlab-ci 发布傻瓜
【发布时间】:2017-11-15 15:51:14
【问题描述】:

我正在尝试使用 gitlab-ci 设置 ci。我有几个问题。

  1. 看起来 gitlab-ci 上没有回滚机制。那么如果部署阶段失败,我应该关心回滚吗?
  2. 我打算使用“dotnet publish Solution.sln -c release”脚本。但是我在这个解决方案中有多个项目。它有 1 个类库和 2 个 api。 (如 AdminApi 和 UserApi)。这 2 个 api 托管在 IIS 中的不同站点。在这种情况下,如何使用参数配置 dotnet 发布脚本?
  3. 我应该使用 xcopy 之类的东西将发布输出移动到 iis 文件夹吗?

【问题讨论】:

    标签: iis .net-core publish gitlab-ci


    【解决方案1】:

    我在 iis 中为每个网站添加了一个app_offile.htm_,并在 html 中使用“我们很快就会回来消息”。

    我已经用这个 gitlab-ci.yml 解决了我的问题

    stages:
        - build
        - test
        - deploy
    build:
        stage: build
        script:
            - echo "Building the app"
            - "dotnet publish MySolution.sln -c release"
        artifacts:
            untracked: true
        only:
            - dev
    test:
        stage: test
        script: echo "Running tests"
        artifacts:
            untracked: true
        dependencies:
            - build
        only:
            - dev
    deploy_staging:
        stage: deploy
        script:
            - echo "Deployintg to staging server Admin"
            - ren c:\\inetpub\\vhosts\\xxx\\admin\\app_offline.htm_ app_offline.htm
            - dotnet publish PathToAdmin.csproj -c release -o c:\\inetpub\\vhosts\\xxx\\admin
            - ren c:\\inetpub\\vhosts\\xxx\\admin\\app_offline.htm app_offline.htm_
            - echo "Deployintg to staging server User"
            - ren c:\\inetpub\\vhosts\\xxx\\user\\app_offline.htm_ app_offline.htm
            - dotnet publish PathToUser.csproj -c release -o c:\\inetpub\\vhosts\\xxx\\user
            - ren c:\\inetpub\\vhosts\\xxx\\user\\app_offline.htm app_offline.htm_
        dependencies:
            - build
        only:
            - dev
    

    【讨论】:

    • 嗨,我得到一个“/bin/bash: line 74: ren: command not found”。知道我的跑步者缺少什么吗?其设置为 executor = "shell"。和你的一样吗?谢谢。
    • 嗨@Vindberg,我的 gitlab 跑步者正在 Windows 服务器上工作。也许您应该将命令替换为与您的环境等效的命令。
    • 已解决。必须删除所有默认的 gitlab 运行程序以确保使用我自己的运行程序。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 2011-10-12
    • 2010-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多