Manual deployment
Manual deployment job
We are going to modify the pipeline as follows:
graph LR;
subgraph build
B(mvn compile);
end
subgraph test
C(mvn test);
D(mvn cobertura:cobertura);
E(mvn checkstyle:checkstyle);
end
subgraph deploy
F(rsync);
end
B-->C
B-->D
B-->E
C-->F
D-->F
E-->F
Manual deployment
Add a deploy
stage, and a job_deployment
in the deploy
stage in the
.gitlab-ci.yml
file using the when: manual
technic.
Specify <YOUR_LOGIN>
in the script to have your own copy of your yaml file on
the target server:
script:
- rsync .gitlab-ci.yml ci@172.21.9.205:<YOUR_LOGIN>-gitlab-ci.yml
when: manual
Secret variables
GitLab CI offers the possibility to define secret variables.
On the GitLab web site, in Settings
, CI / CD
, expand the Variables
.
Check the variables named SSH_PRIVATE_KEY
and SSH_KNOWN_HOSTS
are defined.
This will allow you to push some files on a server.
SSH keys when using the docker executor
Accordingly to the documentation, add the following
before_script
in job_deployment
of the .gitlab-ci.yml
file:
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
Push the .gitlab-ci.yml
file, and verify on the GitLab web site, click on
your Pipeline
, and play the manual job_deployment
.
Home | C++ Home | << C++ Previous - Compilation in a docker container