Let's put all of these skills together once again using the GitLab CI as an example to build our pipeline. Following the testing step, we will add two more steps, one that creates the package and another one that uses Ansible to deploy this package.
All we need for the packaging step is the following:
# Package the application and publish the artifact
package:
stage: package
# Use cpack for packaging
script:
- cd build
- cpack .
# Save the deb package artifact
artifacts:
paths:
- build/Customer*.deb
When we add the package step containing artifacts definitions, we'll be able to download them from the dashboard.
With this, we can invoke Ansible as part of the deployment step:
# Deploy using Ansible
deploy:
stage: deploy
script:
- cd build
- ansible-playbook -i localhost, ansible.yml
The final pipeline would then look like the following:
cache:
key: all
paths:
- .conan
- build
default:
image: conanio/gcc9
stages:
...