# On-Premises Agent Installation Guide

## System Requirements

* **Operating System**: Ubuntu (Debian-based)
* **Ubuntu Version**: 18+ LTS
* **Recommended RAM**: 2GB

## Prerequisites

Before beginning the installation, ensure you have:

* Access to a terminal with sudo privileges
* Bitbucket, GitHub, Jenkins, and SonarQube credentials (if applicable)
* The server's IP address, where the agent will be running, must be whitelisted in Bitbucket/Github/SonarQube Cloud/Server.

## Installation Steps

### 1. Create Workspace Directory

```bash
cd ~

mkdir devdynamics-agent

cd devdynamics-agent
```

### 2. Download Installation Files

Clone the `stormtrooper` in the `devdynamics-agent` directory.

```bash
git clone https://frodo-repo@github.com/devdynamics-ai/stormtrooper.git
```

Contact the DevDynamics team to get the Personal Access token necessary to autheticate the clone request.

### 3. Update System and Install Tools

```bash
sudo apt update

sudo apt install unzip
```

### 4. Extract Installation Files

```bash
unzip stormtrooper.zip

cd stormtrooper
```

### 5. Configure Agent Configuration File

Edit the `dd-agent.conf` file with the following sections:

#### Common Configuration

```plaintext
# Common Configuration

CRON_EXPRESSION='0 * * * *' # Runs every hour by default

ORG_CODE='ABCDEF' # Provided Organization Code

REQUEST_SIZE_THRESHOLD_IN_BYTES='200_000' # DO NOT CHANGE

DD_API_KEY='<dd-api-key>' # DO NOT CHANGE
```

* **`CRON_EXPRESSION`**: Controls the execution frequency. By default, it runs every hour.
* **`ORG_CODE`**: Get your OrgID from <https://app.devdynamics.ai/settings/organisation>.
* **`REQUEST_SIZE_THRESHOLD_IN_BYTES`**: Do not modify this value.
* **`DD_API_KEY`**: Get your OrgID and API key from <https://app.devdynamics.ai/settings/organisation>.

#### GitHub Configuration

```plaintext
# Github Configuration

GITHUB_ENABLED=true

GITHUB_URL='https://api.github.com' # Replace with your Github URL if different (without port)

GITHUB_PORT='443' # Replace with your port if not default (443)

GITHUB_API_TOKENS='<GITHUB_API1>,<GITHUB_API2>'... # Replace with your Github API tokens

GITHUB_ORG_NAME='<GITHUB_ORG_NAME>' # Replace with your Github Organization name
```

* **`GITHUB_ENABLED`**: This must remain `true`.
* **`GITHUB_URL`**: The base URL for your GitHub application (exclude the port number).
* **`GITHUB_PORT`**: Specify the port (default is `443`).
* **`GITHUB_API_TOKENS`**: Add the API token for your GitHub account. We recommend providing at least 3 API tokens to avoid the rate-limiting condition.
* **`GITHUB_ORG_NAME`**: Add your GitHub Organisation's name.

#### Bitbucket Configuration

```plaintext
# Bitbucket Configuration

BITBUCKET_ENABLED=true

BITBUCKET_URL='http://X.X.X.X' # Replace with your Bitbucket URL (without port)

BITBUCKET_PORT='80' # Replace with your port if not default (80)

BITBUCKET_API_KEY='<API_KEY>' # Replace with your Bitbucket API Key

BITBUCKET_USER='<USER_NAME>' # Replace with your Bitbucket username
```

* **`BITBUCKET_ENABLED`**: This must remain `true`.
* **`BITBUCKET_URL`**: The base URL for your Bitbucket application (exclude the port number).
* **`BITBUCKET_PORT`**: Specify the port (default is `80`).
* **`BITBUCKET_API_KEY`**: Add the API token for your Bitbucket account.
* **`BITBUCKET_USER`**: Add your Bitbucket username.

#### Bitbucket Cloud Configuration

```
# Bitbucket Cloud configuration

BITBUCKET_CLOUD_ENABLED='true'

BITBUCKET_CLOUD_API_TOKEN=<API_KEY>' # Replace with your Bitbucket API Token

BITBUCKET_CLOUD_USER='<USER_NAME>' # Replace with your Bitbucket username

BITBUCKET_CLOUD_WORKSPACE='<USER_NAME>' # Replace with your Bitbucket workspace
```

* **`BITBUCKET_ENABLED` :** This must remain `true`.
* **`BITBUCKET_CLOUD_API_TOKEN`** : Add the API token for your Bitbucket account.
* **`BITBUCKET_CLOUD_USER`:** Add your Bitbucket username.
* **`BITBUCKET_CLOUD_WORKSPACE`**: Add the Bitbucket workspace

#### Jenkins Configuration

```plaintext
# Jenkins Configuration

JENKINS_ENABLED=true

JENKINS_URL='http://X.X.X.X' # Replace with your Jenkins URL (without port)

JENKINS_PORT='8765' # Replace with your port if not default (8765)

JENKINS_API_TOKEN='<API_TOKEN>' # Replace with your Jenkins API Key

JENKINS_USERNAME='<USER_NAME>' # Replace with your Jenkins username
```

* **`JENKINS_ENABLED`**: This must remain `true`.
* **`JENKINS_URL`**: The base URL for your Jenkins application (exclude the port number).
* **`JENKINS_PORT`**: Specify the port (default is `8765`).
* **`JENKINS_API_TOKEN`**: Add the API token for your Jenkins account.
* **`JENKINS_USERNAME`**: Add your Jenkins username.

#### SonarQube Configuration

```plaintext
# SonarQube Configuration

SONAR_ENABLED=true

SONAR_URL='http://X.X.X.X' # Replace with your SonarQube URL (without port)

SONAR_PORT='8765' # Replace with your port if not default (8765)

SONAR_API_KEY='<API_KEY>' # Replace with your SonarQube API Key
```

* **`SONAR_ENABLED`**: This must remain `true`.
* **`SONAR_URL`**: The base URL for your SonarQube application (exclude the port number).
* **`SONAR_PORT`**: Specify the port (default is `8765`).
* **`SONAR_API_KEY`**: Add the API token for your SonarQube account.

### 6. Run Installation Script

```bash
sudo chmod +x install-deb.sh

./install-deb.sh <ORG_CODE>
```

### 7. Check the DevDynamics Daemon Service

```bash
sudo systemctl status devdynamics
 
sudo journalctl -u devdynamics
```

## Configuration Notes

* Modify configuration values carefully
* Do not change `REQUEST_SIZE_THRESHOLD_IN_BYTES` or `DD_API_KEY`&#x20;
* Ensure all URLs and credentials are correct.

## Support

For installation issues or questions, contact:

* **Email**: <support@devdynamics.ai>
* **Additional Support**: Use Intercom chat on the DevDynamics website
