Install Third-Party Libraries
Overview
To install third-party libraries in a GitLab CI/CD pipeline, you can specify the installation commands in the before_script
section. This ensures that necessary libraries are installed before the main pipeline tasks begin, making them available for use during the job execution.
For more information, please see Scripts and job logs.
Pre-requisites
Modify the pipeline
Select the project > Build > Pipeline Editor. Paste the code below and commit changes.
workflow:
name: Generate ASCII Framework
ascii_job:
before_script:
- gem install cowsay
script:
- echo "Generating ASCII framework using COWSAY program"
- cowsay -f dragon "Run for cover, I am a mighty DRAGON!" >> dragon.txt
- grep -i "dragon" dragon.txt
- cat dragon.txt
Go to Jobs > Click the ascii_job
.
Using Scripts
Go back to main page and open the .gitlab-ci.yml
file > Edit > Open in Web IDE.
In the Web IDE, create ascii_script.sh
and move the contents of the script section here.
Modify the .gitlab-ci.yml
file.
workflow:
name: Generate ASCII Framework
ascii_job:
before_script:
- gem install cowsay
- chmod +x ./ascii_script.sh
script:
- ./ascii_script.sh
after_script:
- echo "Done executing."
Click the Source Control icon on the left > Add commit message > Commit and push.
Go to Jobs and click the most recent ascii_job
.