与Windows容器配合的Concourse

8
我试图设置一个支持尽可能多语言/平台的Concourse构建服务器(http://concourse-ci.org/)。
我已经了解到,从Windows Server 2016开始,将可以使用Windows容器。由于Concourse在其网站上写道支持多个平台(包括Windows),我想知道这是否意味着可以使用Windows容器?
如果不能运行Windows容器,我是否可以让Concourse代替容器启动虚拟机?

你有没有找到让它工作的方法?我问了,被告知不支持。 - Christopher Painter
2个回答

5
很抱歉,我只能找到一页相关信息。我也尝试过像“Hello World”这样更简单的流水线,但无法使其工作。只是分享,或许有人会从中受益,链接在此。

我省略了生成SSH密钥、准备TSA等部分。

准备Windows Worker

现在我们将关注要转换为Concourse worker的Windows服务器。

首先,我们需要创建一个目录来存放工作服务及其数据的二进制文件,即C:\concourse。

C:\> mkdir concourse
C:\> cd concourse
C:\concourse>

现在从Concourse下载页面下载Windows Concourse二进制文件(例如“concourse_windows_amd64.exe”),并将其放置在我们的工作目录中。另外,我们还需要将“tsakey.pub”和“workerkey”文件复制到那里。
将“tsakey.pub”提供给本地Concourse二进制文件,可以建立我们对于部署中的TSA服务器的加密信任关系。
现在我们准备启动worker,并让它向TSA注册自己。
C:\concourse> .\concourse_windows_amd64.exe worker \
/work-dir .\work /tsa-host <IP of the TSA> \
/tsa-public-key .\tsakey.pub \
/tsa-worker-private-key .\workerkey

如果一切顺利,我们应该会看到类似于以下输出:
{"timestamp":"1478361158.394949198","source":"tsa","message":"tsa.connection.forward-worker.register.done","log_level":1
,"data":{"remote":"<IP:SOURCE-PORT of the TSA>","session":"3.1.4","worker-address":"<IP:PORT of this worker>","worker-platform":"windows",
"worker-tags":""}}

新员工应该通过Concourse CLI出现在列表中,如下所示:

~/  $ fly -t ci workers
name            containers  platform  tags  team
2a334e70-c75c   3           linux     none  none
WORKERSHOSTNAME 0           windows   none  none

测试一些东西

假设.NET框架已经存在于我们的工作机器上,并且构建工具在路径中,我们可以通过构建这个简单的.NET控制台应用程序项目来测试它:https://github.com/chrisumbel/DatDotNet.git

考虑到这个流水线:

resources:  
  - name: code  
    type: git  
    source:  
      uri: https://github.com/chrisumbel/DatDotNet.git  
      branch: master  
jobs:  
  - name: build  
    plan:  
    - aggregate:  
      - get: code  
        trigger: true  
    - task: compile  
      privileged: true  
      file: code/Pipeline/compile.yml

使用构建任务的方法:
platform: windows      
inputs:  
  - name: code  
run:  
  dir: code  
  path: msbuild

请注意构建任务中指定的平台为"windows"。这指示Concourse将任务放置在Windows工作程序上。

如果一切正常,我们应该看到类似以下输出的成功构建:

~/ $ fly -t ci trigger-job -j datdotnet/build --watch
started datdotnet/build #8

using version of resource found in cache
initializing
running msbuild
Microsoft (R) Build Engine version 4.6.1085.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 11/5/2016 4:04:00 PM.
...
nces, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\concourse\work\containers\00000arl2se\tmp\build\36d0981b\code\DatDotNet\DatDotNet.csproj]

    3 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.22
succeeded

这将导致构建发生在工作机上,而不是工作机上的容器中。 - Christopher Painter
如何区分调试和发布配置? - sriramsm04

0
理论上可以通过 Garden-Windows 来实现这一点,因为 Concourse 将所有容器化委托给 Garden API。
我以前从未做过这个,我不知道从哪里开始。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接