博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在本地运行travis-ci
阅读量:2380 次
发布时间:2019-05-10

本文共 5596 字,大约阅读时间需要 18 分钟。

本文翻译自:

I've just joined a project, and I'm new to travis-ci. 我刚加入了一个项目,我是travis-ci的新手。 I'd rather not have to push every little change to .travis.yml and every little change I make to the source in order to run the build. 我宁愿不必将每一个小改动都推到.travis.yml以及我为源代码运行构建所做的每一点改变。 With jenkins you can download jenkins and run locally. 使用jenkins,您可以下载jenkins并在本地运行。 Does travis offer something like this? 特拉维斯提供这样的东西吗?

Note: I've seen the travis-ci cli and downloaded it, but all it seems to do is call their API, which then connects to my github repo, so if I don't push, it won't matter that I restart the last build. 注意:我已经看过travis-ci cli并下载了它,但它似乎只是调用它们的API,然后连接到我的github repo,所以如果我不推送,重启就没关系最后的构建。


#1楼

参考:


#2楼

UPDATE: I now have a complete turnkey, all-in-one answer, see . 更新:我现在有一个完整的交钥匙,一体化答案,请参阅 。 Only took 3 years to figure out! 只花了3年时间搞清楚!

According to the Travis documentation: there is a concoction of projects that collude to deliver the Travis CI web service we know and love. 根据Travis的文档: : 有一个项目的混合物,它们共同提供我们熟悉和喜爱的Travis CI网络服务。 The following subset of projects appears to allow local make test functionality using the .travis.yml in your project: 以下项目子集似乎允许使用项目中的.travis.yml进行本地make test功能:

travis-build 特拉维斯 - 建造

creates the build script for each job. 为每个作业创建构建脚本。 It takes the configuration from the .travis.yml file and creates a bash script that is then run in the build environment by travis-worker. 它从.travis.yml文件获取配置并创建一个bash脚本,然后由travis-worker在构建环境中运行。

travis-cookbooks 特拉维斯 - 食谱

holds the cookbooks that are used to provision the build environments. 拥有用于配置构建环境的 cookbook。

travis-worker 特拉维斯工人

is responsible for running the build scripts in a clean environment. 负责在干净的环境中运行构建脚本。 It streams the log output to travis-logs and pushes state updates (build starting/finishing) to travis-hub. 它将日志输出流式传输到travis-logs并将状态更新(构建开始/结束)推送到travis-hub。

(The other subprojects are responsible for communicating with GitHub, their web interface, email, and their API.) (其他子项目负责与GitHub,他们的Web界面,电子邮件及其API进行通信。)


#3楼

I'm not sure what was your original reason for running Travis locally, if you just wanted to play with it, then stop reading here as it's irrelevant for you. 我不确定你在本地运行Travis的原因是什么,如果你只是想玩它,那就停止在这里阅读,因为这对你来说无关紧要。

If you already have experience with hosted Travis and you want to get the same experience in your own datacenter, read on. 如果您已经拥有托管Travis的经验并希望在自己的数据中心获得相同的体验,请继续阅读。

Since Dec 2014 Travis CI offers an Enterprise on-premises version. 201412月起, Travis CI提供企业内部部署版本。

The pricing is part of the article as well: 定价也是文章的一部分:

The licensing is done per seats, where every license includes 20 users. 许可是按席位完成的,每个许可包括20个用户。 Pricing starts at $6,000 per license, which includes 20 users and 5 concurrent builds. 每个许可证的起价为6,000美元,其中包括20个用户和5个并发版本。 There's a premium option with unlimited builds for $8,500. 这是一个高级选项,无限制,8,500美元。


#4楼

Travis-ci offers a new container-based infrastructure that uses docker. Travis-ci提供了一个使用docker的基于容器的新基础架构。 This can be very useful if you're trying to troubleshoot a travis-ci build by reproducing it locally. 如果您尝试通过在本地再现它来解决travis-ci构建问题,这可能非常有用。 This is taken from Travis CI's . 这取自Travis CI的 。

Troubleshooting Locally in a Docker Image Docker镜像中的本地故障排除

If you're having trouble tracking down the exact problem in a build it often helps to run the build locally. 如果您在跟踪构建中的确切问题时遇到问题,那么在本地运行构建通常会有所帮助。 To do this you need to be using our container based infrastructure (ie, have sudo: false in your .travis.yml ), and to know which Docker image you are using on Travis CI. 为此,您需要使用我们基于容器的基础架构(即,在.travis.yml使用sudo: false ),并了解您在Travis CI上使用的Docker镜像。

Running a Container Based Docker Image Locally 在本地运行基于容器的Docker镜像

  1. Download and install the . 下载并安装 。
  2. Select an image from . 从选择一个图像。 If you're not using a language-specific image pick ci-ruby . 如果您没有使用特定于语言的图片,请选择ci-ruby Open a terminal and start an interactive Docker session using the image URL: 打开终端并使用图像URL启动交互式Docker会话:

    docker run -it travisci/ubuntu-ruby:18.04 /bin/bash
  3. Switch to the travis user: 切换到travis用户:

    su - travis
  4. Clone your git repository into the / folder of the image. 将git存储库克隆到映像的/文件夹中。
  5. Manually install any dependencies. 手动安装任何依赖项。
  6. Manually run your Travis CI build command. 手动运行Travis CI构建命令。

#5楼

Similar to Scott McLeod's but this also generates a bash script to run the steps from the .travis.yml. 与Scott McLeod相似,但这也会生成一个bash脚本来运行.travis.yml中的步骤。

Troubleshooting Locally in Docker with a generated Bash script 使用生成的Bash脚本在Docker中进行本地故障排除

# choose the image according to the language chosen in .travis.yml$ docker run -it -u travis quay.io/travisci/travis-jvm /bin/bash# now that you are in the docker image, switch to the travis usersudo - travis# Install a recent ruby (default is 1.9.3)rvm install 2.3.0rvm use 2.3.0# Install travis-build to generate a .sh out of .travis.ymlcd buildsgit clone https://github.com/travis-ci/travis-build.gitcd travis-buildgem install travis# to create ~/.travistravis versionln -s `pwd` ~/.travis/travis-buildbundle install# Create project dir, assuming your project is `AUTHOR/PROJECT` on GitHubcd ~/buildsmkdir AUTHORcd AUTHORgit clone https://github.com/AUTHOR/PROJECT.gitcd PROJECT# change to the branch or commit you want to investigatetravis compile > ci.sh# You most likely will need to edit ci.sh as it ignores matrix and envbash ci.sh

#6楼

Use ruby gem to run tests on your local machine roughly as they would run on travis. 使用 ruby gem在本地计算机上运行测试,就像在travis上运行一样。

It will recreate the build matrix and run each configuration, great to sanity check setup before pushing. 它将重新创建构建矩阵并运行每个配置,非常适合在推送之前进行完整性检查设置。

gem i wwtdwwtd

转载地址:http://jyexb.baihongyu.com/

你可能感兴趣的文章
《关于信息系统组织方式的一个提案》的评论与反评
查看>>
冒号和他的学生们(连载10)——超级范式
查看>>
冒号和他的学生们(连载9)——泛型范式
查看>>
冒号和他的学生们(连载13)——范式总结
查看>>
A Proposal on Organization of Information System
查看>>
冒号和他的学生们(连载2)——首轮提问
查看>>
正则表达式与文件格式化处理
查看>>
Java EE互联网轻量级框架整合开发
查看>>
Java语言程序设计(基础篇)
查看>>
大型网站技术架构:核心原理与案例分析
查看>>
JAVA并发编程实战
查看>>
RabbitMQ实战++高效部署分布式消息队列
查看>>
微服务设计
查看>>
Spring Cloud微服务实战
查看>>
C++ static 语义
查看>>
C++ static 语义
查看>>
Linux Cgroups概述
查看>>
centos7 硬盘性能测试
查看>>
cgroup使用--cpu资源限制
查看>>
cgroup使用--memory资源限制
查看>>