GitLab CI
1. Add Variable
Section titled “1. Add Variable”Go to Settings > CI/CD > Variables and add:
- Key:
PAKYAS_API_KEY - Value:
pk_live_... - Type: Variable
- Flags: Masked (Recommended), Protected (if used on protected branches)
2. Configure .gitlab-ci.yml
Section titled “2. Configure .gitlab-ci.yml”stages: - build
nightly-job: stage: build script: # Install Pakyas (or use an image that has it); the image needs curl and tar - curl -fsSL https://pakyas.com/install.sh | PAKYAS_INSTALL_DIR=/usr/local/bin sh # Wrap your command - pakyas monitor nightly-build -- ./run_tests.sh only: - schedulesOnly PAKYAS_API_KEY is needed; the CLI takes the organization from the key. Alternatively, store the check’s public ID as a variable and use pakyas monitor --public-id "$PAKYAS_PUBLIC_ID" -- ./run_tests.sh, which needs no API key. See CI and Cron Setup.
PAKYAS_INSTALL_DIR=/usr/local/bin assumes the job runs as root, as in most Docker executors. Otherwise drop it and call ~/.local/bin/pakyas.
Using after_script
Section titled “Using after_script”To ensure pings are sent even if the script crashes, you can use after_script, but keep in mind after_script runs in a separate shell context, so local variables won’t persist.
nightly-job: script: - pakyas ping nightly-build --start - ./hazardous-script.sh only: - schedules after_script: - | if [ "$CI_JOB_STATUS" == "success" ]; then pakyas ping nightly-build else pakyas ping nightly-build --fail fi