Skip to content
Learn Netverks

Lesson

Step 28/36 78% through track

ci-scripts-bash

CI scripts in Bash

Last reviewed May 28, 2026 Content v20260528
Track mode
none
Means
Read / quiz
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches CI scripts in Bash: the syntax, patterns, and safety habits you need before advancing in Bash.

Teams still ship CI scripts in Bash in Bash codebases—skipping it leaves gaps in debugging and code reviews.

You will apply CI scripts in Bash in contexts like: Scheduled backups, CI deploy steps, and release automation on Linux runners.

Read each lesson, copy bash examples into your own terminal, and complete the lesson MCQs—there is no in-browser runner for security reasons.

When you can explain the previous lesson's ideas without copying starter code.

Continuous integration runs your tests on every push. YAML configs call Bash steps—understand exit codes, env vars, and working directories.

Typical CI step

#!/usr/bin/env bash
set -euo pipefail
npm ci
npm test
npm run build

Each line failing stops the job when set -e is on—CI marks the build failed.

GitHub Actions style

- name: Test
  run: |
    chmod +x ./scripts/test.sh
    ./scripts/test.sh

Multi-line run blocks are Bash on Ubuntu runners—same syntax as local.

Artifacts and secrets

CI injects secrets as env vars—never echo them. Cache dependencies between runs; use Bash only for glue, not heavy logic—compare with language-specific test runners.

Important interview questions and answers

  1. Q: Why set -e in CI?
    A: Ensures failing tests fail the pipeline visibly.
  2. Q: Secrets in logs?
    A: Printing env vars can leak tokens—mask secrets in CI settings.

Self-check

  1. What happens when npm test fails under set -e?
  2. Why chmod +x before running a script in CI?

Tip: Keep CI scripts idempotent—re-running should not corrupt state.

Interview prep

set -e in CI?

Ensures failing tests fail the build.

Secrets in logs?

Avoid echoing tokens—use masked CI variables.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • set -euo pipefail?
  • bash -x debug?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump