我可不想把每一个小改动都推给。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

其他回答

可以通过一个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构建环境

使用wwtd (travis会做什么)ruby gem在本地机器上运行测试,大致就像它们在travis上运行一样。

它将重新创建构建矩阵并运行每个配置,在推送之前检查设置。

gem i wwtd
wwtd

类似于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

您可以尝试Trevor,它使用Docker运行Travis构建。

从它的描述来看:

我经常需要为多个版本的Node.js运行测试。但我不想使用n/nvm手动切换版本,也不想仅仅为了运行测试而将代码推到Travis CI。 所以我创造了特雷弗上面写着。travis。yml并在您请求的所有版本中运行测试,就像Travis CI一样。现在,您可以在推送前进行测试,并保持git历史记录干净。

我不能用这里的答案。对于初学者,如前所述,关于在本地运行作业的Travis帮助文档已经删除。我找到的所有博客和文章都是基于这个。新的“调试”模式对我没有吸引力,因为我想避免排队时间和Travis基础设施,直到我对我的更改有了一定的信心。

在我的情况下,我正在更新一个Puppet模块,我不是一个Puppet专家,也不是特别有经验的Ruby, Travis,或他们的生态系统。但是,通过仔细检查Travis CI构建日志,我根据本文和其他地方介绍的技巧和想法构建了一个可行的测试映像。

我无法在CI日志中找到与名称匹配的最近的图像(例如,我可以找到travisci/ CI -sardonyx,但找不到任何带有“xenial”或相同构建名称的图像)。从日志中显示,图像现在通过AMQP传输,而不是我更熟悉的机制。

我找到了一个映像travsci/ubuntu-ruby:16.04,它与我针对特定情况的操作系统相匹配。它没有Travis CI中使用的所有组件,因此我基于此构建了一个新的CI,其中一些组件添加到映像中,另一些组件根据需要在运行时添加到容器中。

所以我不能提供一个明确的程序,抱歉。但我所做的,基本上可以归结为:

Find a recent Travis CI image in Docker Hub matching your target OS as closely as possible. Clone the repository to a build directory, and launch the container with the build directory mounted as a volume, with the working directory set to the target volume Now the hard work: go through the Travis build log and set up the environment. In my case, this meant setting up RVM, and then using bundle to install the project's dependencies. RVM appeared to be already present in the Travis environment but I had to install it; everything else came from reproducing the commands in the build log. Run the tests. If the results don't match what you saw in the Travis CI logs, go back to (3) and see where to go. Optionally, create a reusable image. Dev and test locally and then push and hopefully your Travis results will be as expected.

我知道这是不具体的,可能是显而易见的,你的里程肯定会有所不同,但希望这对某些人有用。我的图像的Dockerfile和README在GitHub上供参考。