Jenkins Implementation Using Jenkinsfile from Git Repository
Step 1: Create Jenkinsfile in Your Git Repository
1. Open your project repository
2. In the root directory, create a file named:
“Jenkinsfile”
3. Paste your provided pipeline script inside this file.
4. Commit and push to Git:
git add Jenkinsfile
git commit \-m "Added Jenkins pipeline"
git push origin main
Step 2: Create Pipeline Job in Jenkins
1. Go to Jenkins Dashboard
2. Click New Item
3. Enter job name (Example: masst-pipeline)
4. Select Pipeline
5. Click OK
Step 3: Configure Pipeline from Git
Scroll to the Pipeline section.
Set:→Definition:→Pipeline script from SCM
SCM:→Git
Enter:
- Repository URL
- Credentials (if private repository)
- Branch (example: */main)
Script Path:
Jenkinsfile
Click Save.
Jenkinsfile Script :
pipeline {
agent any
environment {
// USER CONFIGURATION
INPUT_FILE = "app-release.aab"; CONFIG_FILE = "bluebeetle_config.bm"
SHIELD_LEVEL = "1" // Set to "1" or "2"
MACOS_DOWNLOAD_URL = "https://storage.googleapis.com/masst-assets/Defender-Binary-Integrator/1.0.0/MacOS/MASSTCLI-v1.1.0-darwin-arm64.zip"
LINUX_DOWNLOAD_URL = "https://storage.googleapis.com/masst-assets/Defender-Binary-Integrator/1.0.0/Linux/MASSTCLI-v1.1.0-linux-amd64.zip"
ANDROID_HOME = "/home/snehal_mane/Android/Sdk"
KEYSTORE_FILE = "Bluebeetle.jks"; KEYSTORE_PASSWORD = "bugs@1234"; KEY_ALIAS = "key0"; KEY_PASSWORD = "bugs@1234"
IDENTITY = "Apple Distribution: Bugsmirror Research private limited (BPKUYCFJ74)"
MASST_DIR = "MASSTCLI_EXTRACTED"; ARTIFACTS_DIR = "output"; MASST_ZIP = "MASSTCLI"
}
options { timestamps(); buildDiscarder(logRotator(numToKeepStr: '10')) }
stages {
stage('Setup') {
steps {
checkout scm //dont add this line if you are not using git or any scm, otherwise it will throw error
script {
if (isUnix()) {
sh '''#!/bin/bash
set -e
[[ "$(uname)" == "Darwin" ]] && PLATFORM="MacOS" || PLATFORM="Linux"
echo "$PLATFORM" > platform.txt
'''
env.DETECTED_PLATFORM = readFile('platform.txt').trim()
env.DOWNLOAD_URL = env.DETECTED_PLATFORM == 'MacOS' ? env.MACOS_DOWNLOAD_URL : env.LINUX_DOWNLOAD_URL
sh '''#!/bin/bash
set -e
[ "${DETECTED_PLATFORM}" = "Linux" ] && export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
[ ! -f "${MASST_ZIP}.zip" ] && { curl -L -o "${MASST_ZIP}.zip" "${DOWNLOAD_URL}" || wget -O "${MASST_ZIP}.zip" "${DOWNLOAD_URL}"; }
[ -d "${MASST_DIR}" ] && rm -rf "${MASST_DIR}"
TEMP=$(mktemp -d) && unzip -q "${MASST_ZIP}.zip" -d "${TEMP}"
[ $(find "${TEMP}" -mindepth 1 -maxdepth 1 -type d | wc -l) -eq 1 ] && mv "$(find "${TEMP}" -mindepth 1 -maxdepth 1 -type d)" "${MASST_DIR}" || { mkdir -p "${MASST_DIR}" && mv "${TEMP}"/* "${MASST_DIR}/"; }
chmod +x "$(find "${MASST_DIR}" -type f -name "MASSTCLI*")"
echo "${DETECTED_PLATFORM} ready"
'''
}
}
}
}
stage('Execute') {
steps {
script {
if (isUnix()) {
sh """#!/bin/bash
set -e
[ "${env.DETECTED_PLATFORM}" = "Linux" ] && export PATH=\$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
[ -e "${INPUT_FILE}" ] || { echo "ERROR: ${INPUT_FILE} not found"; exit 1; }
[ -f "${CONFIG_FILE}" ] || { echo "ERROR: ${CONFIG_FILE} not found"; exit 1; }
MASST_EXE=\$(find "${MASST_DIR}" -type f -name "MASSTCLI*" -print -quit)
[ -x "\$MASST_EXE" ] || { echo "ERROR: MASSTCLI executable not found"; exit 1; }
echo "Using Shield Level: ${SHIELD_LEVEL}"
EXT=\$(echo "${INPUT_FILE}" | awk -F. '{print tolower(\$NF)}')
case "\$EXT" in
xcarchive|ipa)
printf "%s\\n" "${SHIELD_LEVEL}" | "\$MASST_EXE" \\
-input="${INPUT_FILE}" \\
-config="${CONFIG_FILE}" \\
-identity="${IDENTITY}"
;;
aab|apk)
[ -f "${KEYSTORE_FILE}" ] || { echo "ERROR: Keystore not found"; exit 1; }
printf "%s\\n" "${SHIELD_LEVEL}" | "\$MASST_EXE" \\
-input="${INPUT_FILE}" \\
-config="${CONFIG_FILE}" \\
-keystore="${KEYSTORE_FILE}" \\
-storePassword=${KEYSTORE_PASSWORD} \\
-alias=${KEY_ALIAS} \\
-keyPassword=${KEY_PASSWORD} \\
-apk
;;
*)
echo "ERROR: Unsupported file type: ${INPUT_FILE}"
exit 1
;;
esac
echo "✅ Build complete"
"""
}
}
}
}
stage('Archive') {
steps {
script {
if (isUnix()) {
sh """#!/bin/bash
mkdir -p "${ARTIFACTS_DIR}"
echo "Build: ${env.DETECTED_PLATFORM} | RELEASE | \$(date)" > "${ARTIFACTS_DIR}/report.txt"
rm -rf "${MASST_DIR}" "${MASST_ZIP}.zip"
"""
}
}
archiveArtifacts artifacts: 'output/**', allowEmptyArchive: true
}
}
}
post {
success { echo "${env.DETECTED_PLATFORM} RELEASE - SUCCESS" }
failure { echo 'Failed' }
}
}
Jenkins Pipeline
Quick Start (3 Steps)
1. Setup (One Time Only)
Edit these lines in Jenkinsfile:
INPUT_FILE = "your-app.aab" ← Your app file name
CONFIG_FILE = "your-config.bm" ← Your config file name
SHIELD_LEVEL = "1" ← Set "1" or "2"
KEYSTORE_FILE = "YourCert.jks" ← Your Keystore file
KEYSTORE_PASSWORD = "your-password" ← Your Keystore password
KEYALIAS = "key0" ← Your Keyalias
KEY_PASSWORD = "your-password" ← Your Key password
IDENTITY = "Apple Distribution:" ← Your Apple Certificate
DOWNLOAD_URL = "" ← Your download url od macos or linux
2. Run Build
Jenkins Dashboard → Your Job → Build with Parameters
↓
☑ Release Build (signed, ready for store)
↓
Click "Build"
3. Download Result
Build #42 → Artifacts → output/ → Download your signed app