Skip to main content

Automating Acumatica Customization Build Process with Jenkins


Introduction

Automating the customization build process in Acumatica improves efficiency, reduces manual effort, and ensures consistency in deployments. In this article, I will share how I automated the customization build process using Jenkins, incorporating high-level design principles.

High-Level Design

The automation consists of multiple stages that streamline the process, including cleanup, code retrieval, solution building, file synchronization, and packaging. The Jenkins pipeline is structured with parameterized Boolean flags that allow selective execution of different stages.

Pipeline Stages

  1. Cleanup Old Files: Removes outdated DLLs and zip files to ensure a fresh build.
  2. Pull Code from Dev Branch: Retrieves the latest source code from the repository.
  3. Build Solution: Uses MSBuild to compile the solution and generate DLLs.
  4. Copy DLL Files: Moves the compiled binaries to the required directories.
  5. Sync Files: Synchronizes files with the remote repository.
  6. Create Zip Files: Packages the built files for deployment.
  7. Commit and Push Changes: Ensures version control and updates the repository with the latest changes.

Jenkins Pipeline Overview

Below is a snippet from the Jenkins pipeline script implementing the automation:

pipeline {

    agent any

    parameters {

        booleanParam(name: 'Cleanup', defaultValue: true, description: 'Cleanup Old Files')

        booleanParam(name: 'PullCode', defaultValue: true, description: 'Pull Latest Code')

        booleanParam(name: 'BuildSolution', defaultValue: true, description: 'Build Solution and DLLs')

        booleanParam(name: 'CopyDllFiles', defaultValue: true, description: 'Copy DLL Files')

        booleanParam(name: 'Sync', defaultValue: true, description: 'Sync Files with Remote Repository')

        booleanParam(name: 'ZipFiles', defaultValue: true, description: 'Create and Backup Zip Files')

        booleanParam(name: 'CommitPush', defaultValue: true, description: 'Commit and Push Changes')

    }

    stages {

        stage('Cleanup Old Files') {

            when { expression { params.Cleanup } }

            steps {

                bat 'del /Q <path>\*.dll <path>\*.zip'

            }

        }

        stage('Pull Code') {

            when { expression { params.PullCode } }

            steps {

                bat '''

                    git pull origin dev_branch

                '''

            }

        }

        stage('Build Solution') {

            when { expression { params.BuildSolution } }

            steps {

                bat 'MSBuild.exe Project.sln /p:Configuration=Release'

            }

        }

        stage('Copy DLL Files') {

            when { expression { params.CopyDllFiles } }

            steps {

                bat 'xcopy /y "<path>\*.dll" "<path>\Bin"'

            }

        }

        stage('Sync Files') {

            when { expression { params.Sync } }

            steps {

                bat 'call Sync.bat'

# Sync.bat ball will synchronize the files from your repository to local repo(any Acumatica tables updated vai sync it will be happened)

            }

        }

        stage('Create Zip Files') {

            when { expression { params.ZipFiles } }

            steps {

                bat 'powershell -ExecutionPolicy Bypass -File CreatePkg.ps1'

#CreatePkg.ps1 file which creates the .Zip files for customization package

            }

        }

        stage('Commit and Push Changes') {

            when { expression { params.CommitPush } }

            steps {

                bat 'git add . && git commit -m "Automated build update" && git push origin dev_branch'

            }

        }

    }

}

Key Benefits

  • Efficiency: Reduces manual intervention in the build and deployment process.
  • Consistency: Ensures all builds follow the same process, minimizing errors.
  • Scalability: Can be extended to support additional automation requirements.
  • Version Control: Automatically commits and pushes changes to maintain source code integrity.

Conclusion

This automated pipeline significantly improves the customization build process for Acumatica. By leveraging Jenkins, scripting, and structured stages, the process becomes streamlined, repeatable, and error-free. This approach can be further enhanced by integrating notifications, testing, and deployment automation.

### CreatePkg.ps1###

Automating Acumatica Package Creation and Backup to S3

Overview

This guide explains how to automate the process of building Acumatica ERP packages using the PX.CommandLine tool, backing them up locally, and uploading them to an AWS S3 bucket. The script ensures package creation, organizes backups, and securely transfers files to S3.

Prerequisites

Before running the script, ensure you have:

  • Acumatica ERP installed with access to PX.CommandLine.exe.
  • AWS CLI installed and configured with valid credentials.
  • PowerShell environment set up on your system.
 

Step 1: Start the Script

Write-Host "Starting script..."

This line prints a message to indicate that the script execution has begun.

 

Step 2: Create Acumatica Packages

The script invokes Acumatica's PX.CommandLine.exe tool to generate multiple ERP packages. Each package represents different functionalities such as base modules, screens, security roles, and financial reports.

Example of package creation:

Write-Host "Creating Base Package"

& "C:\Program Files\Acumatica ERP\AcumaticaVersion\Bin\PX.CommandLine.exe" /method BuildProject /in "C:\Acumatica Packages\BasePackage" /out "C:\Builds\BasePackage.zip" /description "Contains all standard screens except tax-related modules." /level "1"

  • Write-Host: Displays a message in the console.
  • & "PX.CommandLine.exe": Executes the Acumatica package build command.
  • /method BuildProject: Specifies the build action.
  • /in: Path to the input project/package.
  • /out: Destination path for the output ZIP package.
  • /description: Brief details about the package.
  • /level: Assigns a build priority/order.

Repeat this step for other packages, ensuring each module has a unique description and level.

 

Step 3: Backup Packages Locally

To maintain an organized backup system, the script creates a new directory named after the current date.

$todayDate = Get-Date -Format "dd-MM-yyyy"

$destinationDir = "C:\Backups\pkg-backups"

$existingDirs = Get-ChildItem -Path $destinationDir -Directory

$count = 0

 

foreach ($directory in $existingDirs) {

    $creationDate = $directory.CreationTime.ToString("dd-MM-yyyy")

    if ($creationDate -eq $todayDate) { $count++ }

}

 

$newDir = "{0}-{1}" -f $todayDate, $count

New-Item -ItemType Directory -Force -Path "$destinationDir\$newDir"

  • Get-Date -Format "dd-MM-yyyy": Gets the current date in a readable format.
  • Get-ChildItem -Path $destinationDir -Directory: Lists all existing backup directories.
  • New-Item -ItemType Directory -Force: Creates a new directory with the format yyyy-MM-dd-x, where x increments if multiple backups exist for the day.

Copying Build Files to the Backup Directory

Copy-Item -Path "C:\Builds\*zip" -Destination "$destinationDir\$newDir" -Recurse

Write-Host "Files backed up at: $destinationDir\$newDir"

This moves all built packages to the new backup folder.

Renaming Files If Needed

$originalFile = "$destinationDir\$newDir\BasePackage.zip"

$newFile = "$destinationDir\$newDir\BasePackageRenamed.zip"

Copy-Item -Path $originalFile -Destination $newFile -Force

This is useful when multiple versions need to be stored with different names.

 

Step 4: Upload Backups to AWS S3

The final step uploads the backup folder to an S3 bucket for cloud storage.

Set-Location $destinationDir\$newDir

aws s3 cp $destinationDir\$newDir s3://your-s3-bucket/$newDir --recursive

  • Set-Location: Changes the directory to the backup location.
  • aws s3 cp: Uploads all backup files recursively to the S3 bucket.

Once the upload is complete, the script confirms success:

Write-Host "Files uploaded to S3: completed ; S3 URI = s3://your-s3-bucket/$newDir"

exit 0

 

Key Benefits

  • Efficiency: Reduces manual intervention in the build and deployment process.
  • Consistency: Ensures all builds follow the same process, minimizing errors.
  • Scalability: Can be extended to support additional automation requirements.
  • Version Control: Automatically commits and pushes changes to maintain source code integrity.

Conclusion

This automated pipeline significantly improves the customization build process for Acumatica. By leveraging Jenkins, scripting, and structured stages, the process becomes streamlined, repeatable, and error-free. This approach can be further enhanced by integrating notifications, testing, and deployment automation.

Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings