Sitemap

Member-only story

Automating EAR Deployment to JBoss with Bash

5 min readSep 9, 2025

--

When you build a Java application, the final packaged artifact is often an EAR (Enterprise Archive) file. In enterprise setups, deploying this EAR into a JBoss Application Server manually can be time-consuming and error-prone.

That’s why we use deployment scripts — to make the process reliable, repeatable, and faster.

In this post, we’ll break down a sample Bash deployment script for JBoss.

The Script

Here’s the complete script:

#!/bin/bash
set -euo pipefail
...
# (full script shown above)

Now let’s walk through it step by step.

Key Sections Explained

1. Safety and Logging

set -euo pipefail
  • Stops execution if a command fails (-e), if an undefined variable is used (-u), or if a pipeline command fails (-o pipefail).
  • This makes the script more robust.

- The error_exit Function

error_exit() {
log "Error: $1"
exit 1
}

🔹 Purpose

  • Provides a centralized way to handle errors.
  • Whenever something goes wrong, this function is called.

🔹 How it Works

  • $1 is the first argument passed to the function (the error message).

--

--

Nirbhay Singh
Nirbhay Singh

Written by Nirbhay Singh

Technophile, Assistant Vice President at CITI, talks about AI, DevOps, Cloud, SRE, Linux and Programming. https://buymeacoffee.com/nirbhaysingh281