Built with;
Create a bash script that helps the developer to build a project1 on a specified branch in a working git repository.
Script has to be able to ;
- Switch between branches and build from a given branch upon user requests.
- Warn the user if the branch is main or master.
- Create a new branch upon user requests.
- Enable/disable debug mode of maven. (Default must be disabled)
- Allow users to specify the compressed archive format as "zip" or "tar.gz" formats. (Default must be "tar.gz")
- Terminate if any other compressed algorithms are given. (Must use the default if not specified)
- Set the archive name as the selected branch name.
- Set the output directory for compressed archives upon user requests. (Default must be the working directory)
📔 Overview 🔝
This repository contains an assignment project developed under the Patika.dev & Protein DevOps Engineer Bootcamp. Bootstrapper is an initializer script that sets up the machine as instructed. Git Buddy
is an auxiliary script to manage multiple git instances and was originally not a part of the assignment. Build Expert
is the main script that is coded by the terms of the project.
✨ Features 🔝
- Sets the timezone of the machine as UTC+3 (Europe/Istanbul) and enables Network Time Protocol.
- Downloads the latest package information.
- Downloads, installs, and configures Java 18, Apache Maven 3.8.5 , and the latest version of Git SCM.
- Sets the environment variables for the stated technologies above.
- Sets the permissions of the script files.
- Defines system-wide aliases for the scripts for easy use.
- The main goal of this script is to assist the
Build Expert
script by managing multiple git repositories simultaneously.- Searches for all initialized git repositories under the project directory.
- Can terminate all git repositories at the same time.
- Can initialize git instances for all directories under the project directory simultaneously.
- Manages git and maven package manager to fulfill the tasks given by the user.
- Switches between branches and build the project depending on the user requests.
- Warns the user if the branch is main or master.
- Creates a new branch and build the project from it if specified.
- Enables or disables maven debug mode and quiet mode. Also can skip tests.
- Can create compressed artifacts of the project as "zip" or "tar.gz" formats.
- Renames the archive files as
branchName.zip
orbranchName.tar.gz
automatically.- Sets output directory to user-specified directory.
- Cleans the target directory of the maven project.
⚙️ Installation 🔝
- Install VirtualBox and Vagrant to your machine if you do not have them.
- Clone the project to your machine.
- Open your CLI, change directory to project directory, and type
vagrant up
. - Vagrant will configure the virtual machine first then you may test the project.
- Download all of the project files.
- Copy all scripts under the
/shared/scripts
and sample project from/shared/project/java
to your environment. - Execute
bootstrap.sh
first to configure the machine settings. - Run the scripts with the aliases configured or manually from the directories that are stated below.
🔧 Usage 🔝
- Built-in aliases are
gitbuddy
andbuildexpert
. You may execute them if you executedbootstrap.sh
first. - Optionally, you may call the scripts from any directory with an acceptable arguments that are stated below.
- The target directory of Git Buddy scripts is
/opt/project
directory. - The target directory of Build Expert scripts is
/opt/project/java
directory. - You can change these settings by re-defining the
TARGET_DIR
variable within the scripts.
OPTIONS: ARGUMENTS: DESCRIPTION: DEFAULT VALUE:
[-b] <branch_name> Branch name to get the build from. Current Branch
[-f] <zip|tar.gz> Compress format of the artifact. tar.gz
[-p] <artifact_path> Output path of compressed artifacts. Current Directory
[-n] <new_branch> Creates a new branch if applied.
[-q] <true|false> Enable or disable quiet mode. Enabled
[-d] <true|false> Enable or disable debug mode. Disabled
[-t] <true|false> Apply or skip tests. Skip
[-c] Cleans the maven project if applied.
[-h] Shows usage/help.
💻 Technologies 🔝
- Linux
- Bash Scripting ❤️
- Git SCM
- Oracle VM VirtualBox
- Vagrant by HashiCorp
📂 Directories 🔝
Scripts : /opt/scripts
Project Samples : /mnt/project
💾 Submitted Assignment 🔝
You may check out the submitted version of this project here.
Footnotes
-
Java Spring Boot with Maven Package Manager is provided as a sample project and the script is built upon this configuration. (Can be modified to any other project) ↩