Manual deployment
Manual deployment job
We are going to modify the pipeline as follows:
graph LR;
subgraph test
B(Test and coverage);
end
subgraph analysis
C(pylint);
D(pycodestyle);
end
subgraph deploy
E(rsync);
end
B-->C
B-->D
C-->E
D-->E
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 | Python Home | << Python Previous Compilation in a docker container