Travis-CI - 自己ubuntu-ssh

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/evilparadise/article/details/80365392

1 用Github账户登陆Travis-CI,激活这次要实现自动化部署的仓库,

2在本地项目根目录的master分支里面添加 .travis.yml 配置文件

language: c
dist: trusty
sudo: required
addons:
  apt:
    update: true
    sources:
    - ubuntu-toolchain-r-test
    - llvm-toolchain-precise-3.8
    packages:
    - linux-headers-$(uname -r)
    - gcc
    
compiler:
- gcc

3push .travis.yml文件,至此完成常规操作

4 travis ci 使用 ssh 登录自己的linux机器

ssh-keygen -t rsa # 然后一路回车即可# ssh-copy-id 可能需要另行安装# 如果ssh默认端口是22,则不需要 -p
ssh-copy-id <登录部署服务器用户名>@<部署服务器地址> -p <部署服务器ssh端口>
ssh <登录部署服务器用户名>@<部署服务器地址> -p <部署服务器ssh端口>

5登录服务器成功,然后安装travis

sudo apt install ruby ruby-dev
sudo gem install travis
# install path: /var/lib/gems/

6登录travis,把密码上传travis,gitpush就可以在travis网页中看到

root@caoxudong:~# travis login
Shell completion not installed. Would you like to install it now? |y| y
We need your GitHub login to identify you.
This information will not be sent to Travis CI, only to api.github.com.
The password will not be displayed.

Try running with --github-token or --auto if you don't want to enter your passwo                                 rd anyway.

Username: cxd0513
Password for cxd0513: *************
root@caoxudong:~/dpdk# travis encrypt-file ~/.ssh/id_rsa --add
Detected repository as cxd0513/dpdk, is this correct? |yes| yes
encrypting /root/.ssh/id_rsa for cxd0513/dpdk
storing result as id_rsa.enc
storing secure env variables for decryption

Make sure to add id_rsa.enc to the git repository.
Make sure not to add /root/.ssh/id_rsa to the git repository.
Commit all changes to your .travis.yml.
可以看到yml文件中出现了信息
root@caoxudong:~/dpdk# cat .travis.yml
language: c
dist: trusty
sudo: required
addons:
  apt:
    update: true
    sources:
    - ubuntu-toolchain-r-test
    - llvm-toolchain-precise-3.8
    packages:
    - linux-headers-$(uname -r)
    - gcc
    
compiler:
- gcc

before_install:
- openssl aes-256-cbc -K $encrypted_91258f690662_key -iv $encrypted_91258f690662_iv
  -in id_rsa.enc -out ~\/.ssh/id_rsa -d

最后贴出完整yml信息

language: c
dist: trusty
sudo: required
addons:
  apt:
    update: true
    sources:
    - ubuntu-toolchain-r-test
    - llvm-toolchain-precise-3.8
    packages:
    - linux-headers-$(uname -r)
    - gcc
    - linux-libc-dev
    - libpopt-dev
    - libssl-dev
    - libnuma-dev
    - curl
    - sshpass
compiler:
- gcc
install:
- curl www.qq.com

-  ssh root@ip(填自己ip)-o stricthostkeychecking=no ' git clone https://github.com/*******.git '
script:- sudo sh -c ' echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages'
        - cat /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
before_install:- openssl aes-256-cbc -K $encrypted_91258f690662_key -iv $encrypted_91258f690662_iv -in id_rsa.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host ip(填自己ip)\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config



猜你喜欢

转载自blog.csdn.net/evilparadise/article/details/80365392