如何在Docker中运行.Net项目作为jenkins工作的一部分

我正在使用jenkins持续整合.net项目。 到目前为止,我能够在窗口中设置jenkins的工作。 但是现在我需要在作为docker集装箱运行的jenkins中复制这一切。 我能够在Docker中启动jenkins,使用github作为源代码库,但是当我尝试构build这个项目时,它失败了。 我的项目是使用asp.net核心,所以我假设它也应该在Linux上运行(这是docker虚拟机的操作系统)。 我在这里错过了什么? 任何帮助,高度赞赏

我正在使用.Net核心开发一个项目,我们开始在Docker容器中使用Jenkins,到目前为止,我发现的唯一方法是创build一个自定义的Jenkins图像。 这是我的docker文件:

FROM jenkins USER root # Work around https://github.com/dotnet/cli/issues/1582 until Docker releases a # fix (https://github.com/docker/docker/issues/20818). This workaround allows # the container to be run with the default seccomp Docker settings by avoiding # the restart_syscall made by LTTng which causes a failed assertion. ENV LTTNG_UST_REGISTER_TIMEOUT 0 # Install .NET CLI dependencies RUN apt-get update \ && apt-get install -y --no-install-recommends \ libc6 \ libcurl3 \ libgcc1 \ libgssapi-krb5-2 \ libicu52 \ liblttng-ust0 \ libssl1.0.0 \ libstdc++6 \ libunwind8 \ libuuid1 \ zlib1g \ && rm -rf /var/lib/apt/lists/* # Install .NET Core SDK ENV DOTNET_SDK_VERSION 1.0.0-preview2-003131 ENV DOTNET_SDK_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/$DOTNET_SDK_VERSION/dotnet-dev-debian-x64.$DOTNET_SDK_VERSION.tar.gz RUN curl -SL $DOTNET_SDK_DOWNLOAD_URL --output dotnet.tar.gz \ && mkdir -p /usr/share/dotnet \ && tar -zxf dotnet.tar.gz -C /usr/share/dotnet \ && rm dotnet.tar.gz \ && ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet # Trigger the population of the local package cache ENV NUGET_XMLDOC_MODE skip RUN mkdir warmup \ && cd warmup \ && dotnet new \ && cd .. \ && rm -rf warmup \ && rm -rf /tmp/NuGetScratch USER jenkins 

我仍然在寻找更好的方法来做到这一点。

Jenikins任务应该调用dotnet命令来构build。 MSBuild尚不支持dotnet

基本上,它必须做一些类似于我们在KoreBuild中做的事情 :

  1. dotnet恢复
  2. dotnet build / dotnet发布
  3. dotnettesting

等等