Sitemap

Build Automation & CI Pipeline

3 min readMay 12, 2026

--

1. Install Node.js

Download dan install Node.js dulu: Node.js Official Website

2. Buat Folder Project

Buka:

  • CMD

lalu ketik dibawah ini:

mkdir tugas-devops

masuk ke folder:

cd tugas-devops
Press enter or click to view image in full size

3. Inisialisasi Project Node.js

npm init -y
Press enter or click to view image in full size

Nanti otomatis akan membuat file: package.json

4. Install Express.js

npm install express
Press enter or click to view image in full size

5. Install Dev Dependencies

npm install --save-dev nodemon eslint jest supertest
Press enter or click to view image in full size

Buat File Server

1. Buat file index.js

const express = require("express");

const app = express();

app.get("/", (req, res) => {
res.send("Hello DevOps");
});

app.listen(3000, () => {
console.log("Server berjalan di port 3000");
});
Press enter or click to view image in full size

2. Setup npm Scripts

Buka file:

package.json

Cari bagian:

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}

Ubah jadi:

"scripts": {
"dev": "nodemon index.js",
"start": "node index.js",
"build": "echo Build Success",
"test": "jest",
"lint": "eslint ."
}
Press enter or click to view image in full size

Jalankan Nodemon:

npm.cmd run dev
Press enter or click to view image in full size

3. Setup ESLint

Get musa okta’s stories in your inbox

Join Medium for free to get updates from this writer.

ketik:

npx.cmd eslint --init
Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

TEST LOKAL

1. Jalankan ESLint

npm.cmd run lint

2. Buat Folder test

Press enter or click to view image in full size

3. Buat File app.test.js

Klik kanan folder test -> new file

4. Isi app.test.js

const request = require("supertest");
const app = require("../index");

describe("GET /", () => {
it("should return Hello DevOps", async () => {
const res = await request(app).get("/");

expect(res.statusCode).toBe(200);
expect(res.text).toBe("Hello DevOps");
});
});

5. Ubah isi index.js

const express = require("express");

const app = express();

app.get("/", (req, res) => {
res.send("Hello DevOps");
});

if (require.main === module) {
app.listen(3000, () => {
console.log("Server berjalan di port 3000");
});
}

module.exports = app;

6. Jalankan Test

npm.cmd test
Press enter or click to view image in full size

PUSH KE GITHUB

git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/Musakings/tugas-devops.git
git branch -M main
git push -u origin main
Press enter or click to view image in full size

Hasil

Press enter or click to view image in full size

GitHub Actions

Press enter or click to view image in full size
Press enter or click to view image in full size

Link GitHub : https://github.com/Musakings/tugas-devops

--

--