如何build立docker图像frome .drone.yml?

我有一个(.drone.yml)testing文件,我想从中build立一个泊坞窗图像。 根据文件,我必须使用无人机build立它。

我试过这个教程( https://www.digitalocean.com/community/tutorials/how-to-perform-continuous-integration-testing-with-drone-io-on-coreos-and-docker )和其他几个教程,但我失败了 。

任何人都可以告诉我一个简单的方法来build立.drone.yml! 谢谢

请注意,这个答案适用于无人机版本0.5

您可以使用Docker插件在成功完成构build时构build和发布Docker镜像。 您将Docker插件添加为.drone.yml文件的构buildpipe线部分中的一个步骤:

pipeline: build: image: golang commands: - go build - go test publish: image: plugins/docker repo: foo/bar 

在很多情况下,您会希望将此步骤的执行限制在某些分支上。 这可以通过添加运行时条件来完成:

  publish: image: plugins/docker repo: foo/bar when: branch: master 

您将需要为您的Dockerregistry提供无人机凭据,以便无人机发布。 这些凭据可以直接在yaml文件中声明,但是通常不build议在yaml中以纯文本forms存储这些值:

  publish: image: plugins/docker repo: foo/bar username: johnsmith password: pa55word when: branch: master 

您也可以使用内置的秘密存储提供您的凭据。 可以使用Drone命令行实用程序以秘密存储库的forms将秘密添加到每个存储库:

  export DRONE_SERVER=http://drone.server.address.com export DRONE_TOKEN=... drone secret add \ octocat/hello-world DOCKER_USERNAME johnsmith drone secret add \ octocat/hello-world DOCKER_PASSWORD pa55word drone sign octocat/hello-world 

秘密然后插入你的yaml rutnime:

  publish: image: plugins/docker repo: foo/bar username: ${DOCKER_USERNAME} password: ${DOCKER_PASSWORD} when: branch: master