我可不想把每一个小改动都推给。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
其他回答
使用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上供参考。
使用https://docs.travis-ci.com/user/common-build-problems/#troubleshooting-locally-in-a-docker-image和https://github.com/travis-ci/travis-build#use-as-addon-for-travis-cli指定的镜像。
编辑2019-12-06
#故障排除-local -in-a-docker-image部分被#running-builds-in-debug-mode所取代,它还描述了如何SSH到在调试模式下运行的作业。
编辑2019-07-26
#troubleshooting-local -in-a-docker-image部分不再是文档的一部分;这是为什么
https://github.com/travis-ci/docs-travis-ci-com/issues/2342 https://blog.travis-ci.com/2018-10-04-combining-linux-infrastructures https://blog.travis-ci.com/2018-11-30-announcing-xenial-build-environment-for-enterprise
但是,它仍然在git历史记录中:https://github.com/travis-ci/docs-travis-ci-com/pull/2193。
在https://travis-ci.org/travis-ci/docs-travis-ci-com/builds/230889063#L661上寻找(相当旧的,找不到更新的)图像版本。
我想检查为什么我的构建中的一个测试失败了,并出现了一个我没有在本地得到的错误。
工作。
真正起作用的是使用Docker image文档页面中“故障排除本地”中指定的图像。在我的例子中,它是travisci/ci-garnet:packer-1512502276-986baf0。
我能够按照https://github.com/travis-ci/travis-build#use-as-addon-for-travis-cli中描述的步骤添加旅行编译。
dm@z580:~$ docker run --name travis-debug -dit travisci/ci-garnet:packer-1512502276-986baf0 /sbin/init
dm@z580:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
travisci/ci-garnet packer-1512502276-986baf0 6cbda6a950d3 11 months ago 10.2GB
dm@z580:~$ docker exec -it travis-debug bash -l
root@912e43dbfea4:/# su - travis
travis@912e43dbfea4:~$ cd builds/
travis@912e43dbfea4:~/builds$ git clone https://github.com/travis-ci/travis-build
travis@912e43dbfea4:~/builds$ cd travis-build
travis@912e43dbfea4:~/builds/travis-build$ mkdir -p ~/.travis
travis@912e43dbfea4:~/builds/travis-build$ ln -s $PWD ~/.travis/travis-build
travis@912e43dbfea4:~/builds/travis-build$ gem install bundler
travis@912e43dbfea4:~/builds/travis-build$ bundle install --gemfile ~/.travis/travis-build/Gemfile
travis@912e43dbfea4:~/builds/travis-build$ bundler binstubs travis
travis@912e43dbfea4:~/builds/travis-build$ cd ..
travis@912e43dbfea4:~/builds$ git clone --depth=50 --branch=master https://github.com/DusanMadar/PySyncDroid.git DusanMadar/PySyncDroid
travis@912e43dbfea4:~/builds$ cd DusanMadar/PySyncDroid/
travis@912e43dbfea4:~/builds/DusanMadar/PySyncDroid$ ~/.travis/travis-build/bin/travis compile > ci.sh
travis@912e43dbfea4:~/builds/DusanMadar/PySyncDroid$ sed -i 's,--branch\\=\\\x27\\\x27,--branch\\=master,g' ci.sh
travis@912e43dbfea4:~/builds/DusanMadar/PySyncDroid$ bash ci.sh
特拉维斯的一切。Yml按预期执行(安装依赖项,运行测试,…)。
注意,在运行bash ci.sh之前,我必须将——branch\=\'\'\改为——branch\=master\(请参阅倒数第二个sed -i…命令)。
如果这不起作用,下面的命令将帮助识别目标行号,您可以手动编辑该行。
travis@912e43dbfea4:~/builds/DusanMadar/PySyncDroid$ cat ci.sh | grep -in branch
840: travis_cmd git\ clone\ --depth\=50\ --branch\=\'\'\ https://github.com/DusanMadar/PySyncDroid.git\ DusanMadar/PySyncDroid --echo --retry --timing
889:export TRAVIS_BRANCH=''
899:export TRAVIS_PULL_REQUEST_BRANCH=''
travis@912e43dbfea4:~/builds/DusanMadar/PySyncDroid$
没有工作。
遵循这个问题的公认答案,但没有 在https://hub.docker.com/u/travisci/上找到实例提到的映像(travis-ci-garnet-trusty-1512502259-986baf0)。
Build worker version指向travis-ci/worker commit及其travis-worker-install引用码头。Io /travisci/镜像注册表。所以我试了一下。
dm@z580:~$ docker run -it -u travis quay.io/travisci/travis-python /bin/bash
travis@370c23a773c9:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
travis@370c23a773c9:/$
dm@z580:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/travisci/travis-python latest 753a216d776c 3 years ago 5.36GB
绝对不是可靠的(Ubuntu 14.04),也不小。