Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Travis CI is used to continuously integrate your project.

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Here the continuous integration of blogs based on GitHub is a project.

Tools:

Introduction to zqz@ubuntu:~$ node-- versionv4.2.6zqz@ubuntu:~$ git-- versiongit version 2.7.4zqzobubuntu version1.8.4Travis CI

Travis CI is an emerging open source continuous integration construction project, which is obviously different from jenkins,GO in that it adopts yaml format, which is simple, fresh and unique. Currently, most github projects have been moved to the Travis CI build queue, and Travis CI is said to run more than 4000 full builds a day.

Note: before you start installing a lot of stuff, you need to sign up for an account on Travis CI. (github account is usually used)

Installation under Linux (strongly recommended that you do not use windows to CI)

Deploy Key

Generate a ssh key to communicate with the warehouse

Ssh-keygen-t rsa-C "youremail@example.com"

After success, add the file ending with .pub to the github repository

Finally, copy the id_rsa file to the root directory of our project, which makes it easy to generate the key.

Cp / home/zqz/.ssh_ci/id_rsa / home/zqz/study/zhaoqize.github.io install and log in to travis

Installation

Gem install travis

After successful installation, log in to travis

Travis login-auto

Login succeeded:

Successfully logged in as zhaoqize!

Next, log on to the web version and set up the warehouse.

Click the gear to the left of the warehouse name and set to open the following three.

Encrypt

Before encrypting, let's create a new .travis.yml file in the project and directory.

What is encrypted is the key id_rsa generated in the first step. Since we copied the key to the project directory earlier, there is now an id_rsa file.

/ / enter the project directory cd study/study/zhaoqize.github.io / / to encrypt travis encrypt-file ssh_key-- add

Encryption succeeded:

Zqz@ubuntu:~/study/zhaoqize.github.io$ travis encrypt-file id_rsa-- addDetected repository as zhaoqize/blog, is this correct? | yes | encrypting id_rsa for zhaoqize/blogstoring result as id_rsa.encstoring secure env variables for decryptionMake sure to add id_rsa.enc to the git repository.Make sure not to add id_rsa to the git repository.Commit all changes to your .travis.yml.

At this point, look at the last sentence * * Commit all changes to your .travis.yml.

One sentence of our new file has changed, adding one more sentence: (private content is replaced by XXX)

-openssl aes-256-cbc-K $encrypted_XXXXXXXX_key-iv $encrypted_XXXXXXXX_iv-in id_rsa.enc-out ~ / .ssh/id_rsa-d

Look at our travis ci page again and find that there are some changes

.travis folder

Delete the id_rsa file that we previously copied to the root directory

Create a new .travis folder under the root of the project

Move the generated .enc file to a .travis file

Ssh_config

Create the ssh_config file under .travis.

And fill in the following information:

Host github.com User git StrictHostKeyChecking no IdentityFile / .ssh/id_rsa IdentitiesOnly yes

Note that the path of ~ / .ssh/id_rsa here varies according to individual settings.

.travis.yml

Finally, you need to focus on configuring the .travis.yml file, thinking that travis ci is executed according to this file.

Specific configuration:

# language used language: nodejs version used by node_js# node_js:-4.4.The branches: only:-master# branch of the repository needs to be executed before executing isntall. Before_install:# configuration decryption information-openssl aes-256-cbc-K $encrypted_4bba640059d8_key-iv $encrypted_4bba640059d8_iv-in. Travis / id_rsa.enc-out ~ / .ssh/id_rsa-d # change the text Ssh/id_rsa# configuration ssh- eval $(ssh-agent)-ssh-add ~ / .ssh/id_rsa-cp .travis / ssh_config ~ / .ssh / config# configure git personal information-git config-- global user.name 'zqz'-git config-- global user.email zqz@zhaoqize.com# execute installinstall:-npm install hexo-cli-g-npm install# execute command script script:-hexo clean-hexo g-d successful

Problems encountered in installation and use failed to install travis

Use sudo permissions to operate

Zqz@ubuntu:~$ gem install travisFetching: ffi-1.9.14.gem ERROR: While executing gem. (Gem::FilePermissionError) You don't have write permissions for the / var/lib/gems/2.3.0 directory.zqz@ubuntu:~$ sudo gem install travisBuilding native extensions. This could take a while.

Modify the directory of travis

Zqz@ubuntu:~$ travis-- versionbash: / usr/bin/travis: no file or directory zqz@ubuntu:~$ sudo ln-s / usr/local/bin/travis / usr/bin/travis [sudo] zqz password: zqz@ubuntu:~$ travis-- version1.8.4zqz@ubuntu:~$ generates .enc file key failed

Sometimes they fail. At this point, we need to add some parameters to the end.

Travis encrypt-file ssh_key-- add-r zhaoqize/blog

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report