The travis configuration needs changes to recurse submodules from private gitlab repository.
Steps to enable ssh support with travis and gitlab are as follows:
-
Generate an ssh keypair to be used with CI
mkdir -p ~/travis ssh-keygen -t rsa -b 4096 -N "" -f ~/travis/deploy_key
-
Add the ssh key to travis
gem install travis cd <REPOSITORY> travis encrypt-file ~/travis/deploy_key --pro --add
The last command will automatically generate and set two environment variables
encrypted_<STRING>_key
andencrypted_<STRING>_iv
in the repository settings of travis. They are not to be removed. -
Change the value of
-out
option inbefore_install: - openssl
to./deploy_key
-
Commit the updated .travis.yml file and the generated file
deploy_key.enc
-
Append the following lines to .travis.yml under
before_install
- eval "$(ssh-agent -s)" - chmod 600 ./deploy_key - ssh-add ./deploy_key
-
Add the following lines to .travis.yml under
install
- SSH_KEY_PRIVATE=$(cat deploy_key) - bash install-package.sh --package=$PACKAGE --branch=$TRAVIS_BRANCH --commit=$TRAVIS_COMMIT --pullrequest=$TRAVIS_PULL_REQUEST --ssh --ssh-key="$SSH_KEY_PRIVATE"
- In the repository Settings > CI/CD > Deploy Keys, add the public key from the file ~/travis/deploy_key.pub