我可不想把每一个小改动都推给。travis。yml和我对源代码所做的每一个小更改,以便运行构建。使用jenkins,您可以下载jenkins并在本地运行。特拉维斯会提供这样的东西吗?
注意:我已经看到了travis-ci命令行并下载了它,但它似乎 要做的就是调用他们的API,然后连接到我的GitHub回购,所以如果 我不推,重启最后的构建也没有关系。
我可不想把每一个小改动都推给。travis。yml和我对源代码所做的每一个小更改,以便运行构建。使用jenkins,您可以下载jenkins并在本地运行。特拉维斯会提供这样的东西吗?
注意:我已经看到了travis-ci命令行并下载了它,但它似乎 要做的就是调用他们的API,然后连接到我的GitHub回购,所以如果 我不推,重启最后的构建也没有关系。
当前回答
类似于Scott McLeod的,但它也生成一个bash脚本来运行.travis.yml中的步骤。
在Docker中使用生成的Bash脚本进行本地故障排除
# 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 user
sudo - travis
# Install a recent ruby (default is 1.9.3)
rvm install 2.3.0
rvm use 2.3.0
# Install travis-build to generate a .sh out of .travis.yml
cd builds
git clone https://github.com/travis-ci/travis-build.git
cd travis-build
gem install travis
# to create ~/.travis
travis version
ln -s `pwd` ~/.travis/travis-build
bundle install
# Create project dir, assuming your project is `AUTHOR/PROJECT` on GitHub
cd ~/builds
mkdir AUTHOR
cd AUTHOR
git clone https://github.com/AUTHOR/PROJECT.git
cd PROJECT
# change to the branch or commit you want to investigate
travis compile > ci.sh
# You most likely will need to edit ci.sh as it ignores matrix and env
bash ci.sh
其他回答
更新:我现在有一个完整的交钥匙,全能的答案,见https://stackoverflow.com/a/49019950/300224。只花了3年时间就弄明白了!
根据Travis文档:https://github.com/travis-ci/travis-ci,有一个混合的项目,共同提供我们所了解和喜爱的Travis CI web服务。下面的项目子集似乎允许使用.travis进行本地make测试功能。Yml在你的项目中:
travis-build
Travis-build创建构建 为每个作业编写脚本。它从.travis中获取配置。Yml文件和 创建bash脚本,然后在构建环境中通过 travis-worker。
travis-cookbooks
Travis-cookbooks拥有 用于提供构建环境的Chef烹饪书。
travis-worker
工人负责 在干净的环境中运行构建脚本。它将日志输出流发送到 travis-log和推送状态更新(构建开始/完成) travis-hub。
(其他子项目负责与GitHub、他们的web界面、电子邮件和他们的API通信。)
Travis-ci提供了一个新的基于容器的基础设施,它使用docker。如果您试图通过在本地复制travis-ci构建来排除故障,这可能非常有用。这是从特拉维斯·CI的文档中截取的。
在Docker映像中进行本地故障排除
如果在跟踪构建中的确切问题时遇到困难,在本地运行构建通常会有所帮助。要做到这一点,你需要使用我们基于容器的基础设施(例如,在你的. Travis .yml中有sudo: false),并知道你在Travis CI上使用的是哪个Docker映像。
本地运行基于容器的Docker镜像
下载并安装Docker引擎。 从Docker Hub中选择一个映像。如果您不使用特定于语言的映像,则选择ci-ruby。打开终端,使用镜像URL启动交互式Docker会话: Docker运行- travisci/ubuntu-ruby:18.04 /bin/bash 切换到travis用户: Su - Travis 将git存储库克隆到映像的/文件夹中。 手动安装任何依赖项。 手动运行Travis CI构建命令。
可以通过一个bounce主机SSH到Travis CI环境。该特性不是在Travis CI中构建的,但是可以通过以下步骤实现。
On the bounce host, create travis user and ensure that you can SSH to it. Put these lines in the script: section of your .travis.yml (e.g. at the end). - echo travis:$sshpassword | sudo chpasswd - sudo sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config - sudo service ssh restart - sudo apt-get install sshpass - sshpass -p $sshpassword ssh -R 9999:localhost:22 -o StrictHostKeyChecking=no travis@$bouncehostip Where $bouncehostip is the IP/host of your bounce host, and $sshpassword is your defined SSH password. These variables can be added as encrypted variables. Push the changes. You should be able to make an SSH connection to your bounce host.
来源:Shell到Travis CI构建环境。
下面是完整的例子:
# use the new container infrastructure
sudo: required
dist: trusty
language: python
python: "2.7"
script:
- echo travis:$sshpassword | sudo chpasswd
- sudo sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config
- sudo service ssh restart
- sudo apt-get install sshpass
- sshpass -p $sshpassword ssh -R 9999:localhost:22 -o StrictHostKeyChecking=no travisci@$bouncehostip
参见:c-mart/travis-shell在GitHub。
请参见:如何为调试重现一个travis-ci构建环境
您可以尝试Trevor,它使用Docker运行Travis构建。
从它的描述来看:
我经常需要为多个版本的Node.js运行测试。但我不想使用n/nvm手动切换版本,也不想仅仅为了运行测试而将代码推到Travis CI。 所以我创造了特雷弗上面写着。travis。yml并在您请求的所有版本中运行测试,就像Travis CI一样。现在,您可以在推送前进行测试,并保持git历史记录干净。
使用wwtd (travis会做什么)ruby gem在本地机器上运行测试,大致就像它们在travis上运行一样。
它将重新创建构建矩阵并运行每个配置,在推送之前检查设置。
gem i wwtd
wwtd