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

标签 jenkins docker continuous-integration asp.net-core

我正在使用 jenkins 持续集成 .net 项目。到目前为止,我可以在窗口中设置 Jenkins 工作。但现在我需要在作为 docker 容器运行的 jenkins 中复制这一切。我可以在 docker 中启动 jenkins,使用 github 作为源存储库,但是当我尝试构建这个项目时,它失败了。我的项目使用的是 asp.net core,所以我假设它也应该在 Linux 上运行(这是 docker 虚拟机的操作系统)。 我在这里缺少什么?非常感谢任何帮助

最佳答案

我正在开发一个使用 .Net core 的项目,我们开始在 Docker 容器中使用 Jenkins,到目前为止,我发现的唯一方法是创建自定义 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

我仍在寻找更好的方法。

关于jenkins - 如何在 Docker 中运行 .Net 项目作为 jenkins 作业的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38497710/

相关文章:

docker - 通过docker exec sh -c “…”传递复杂的Shell脚本

github - 如何避免 Github Actions 中的代码重复; yaml 中有某种循环吗?

build - 当多个 VCS 根附加到构建配置时 TeamCity VCS 触发

windows - Jenkins Windows Master 连接到 Slave Mac OSX

Jenkins 管道 NoSuchMethodError (copyArtifacts)

docker-compose 使用独特的环境变量进行缩放

docker - docker 1.9.1,不会停止docker容器

continuous-integration - 使用 Terraform 时的最佳实践

Jenkins - 共享库 CpsCompilationErrorsException - 无法解析类

jenkins - 'build now' 和 'build with parameters' 是否可以在 Jenkins 管道中共存?