2
2
2
batch: true
branches:
exclude:
- Prod_validation
paths:
include:
- force-app/main/default/*
exclude:
- README.md
stages:
- stage: Validate
condition: eq(variables['Build.Reason'], 'Manual')
jobs:
- job: ValidateChanges
displayName: Validate Changes
pool:
name: IblPool
steps:
- task: 6d15af64-176c-496d-b583-fd2ae21d4df4@1
inputs:
repository: self
fetchDepth: 0
persistCredentials: true
clean: true
- task: CmdLine@2
displayName: 'Check Working Directory and Git Status'
inputs:
script: |
git status
workingDirectory: $(Build.SourcesDirectory)
- task: CmdLine@2
displayName: 'Print Commit History'
inputs:
script: |
git log --oneline -n 5
workingDirectory: $(Build.SourcesDirectory)
- task: DownloadSecureFile@1
displayName: 'Download server.key'
inputs:
secureFile: 'prod.key'
downloadPath: '$(Agent.TempDirectory)/prod.key'
retryCount: 3
cleanDestinationFolder: true
- task: CmdLine@2
displayName: 'Install SFDX'
inputs:
script: |
echo Start the installation process...
where npm
npm --version
npm install --global sfdx-cli
echo Installation done...
- task: CmdLine@2
displayName: 'Set PATH for SFDX'
inputs:
script: |
set PATH=%PATH%;C:\Users\%USERNAME%\AppData\Roaming\npm
- task: CmdLine@2
displayName: 'Verify SFDX installation'
inputs:
script: |
sfdx --version
- task: CmdLine@2
displayName: 'Install sfdx-git-delta plugin'
inputs:
script: |
sfdx plugins:install salesforcedx@latest
sfdx plugins:install sfdx-git-delta
- task: CmdLine@2
displayName: 'Use SOAP API for Deployment'
inputs:
script: |
sfdx config:set restDeploy=false --global
- task: CmdLine@2
displayName: 'Config set'
inputs:
script: |
sfdx config set org-instance-url=https://indusindbank.my.salesforce.com
--json
- task: CmdLine@2
displayName: 'Authorize sandbox'
inputs:
script: |
sfdx force:auth:jwt:grant -i
3MVG9t54FAeH5Yn0RtZfHYLfd.Qm7tcyqOuwiPM6PuhATgckymH5SuHYaqoP9xOdbwjON7ASHhdc8V4HahZ
nX -f $(Agent.TempDirectory)/prod.key --username mangali.rambabu@indusind.com -r
https://indusindbank.my.salesforce.com -a Rambabu_PROD
- task: CmdLine@2
displayName: 'Check for delta changes'
inputs:
script: |
echo y | sfdx sgd:source:delta --api-version="59.0" --to "HEAD" --from
"HEAD~1" --output "."
- task: CmdLine@2
displayName: 'Show generated delta package.xml'
inputs:
script: |
type package\package.xml
- task: CmdLine@2
displayName: 'Show destructiveChanges.xml'
inputs:
script: |
type destructiveChanges\destructiveChanges.xml
- task: CmdLine@2
displayName: 'Validate source code'
inputs:
script: |
sfdx force:source:deploy -c -x package\package.xml -u
mangali.rambabu@indusind.com --wait 60
- stage: CodeCoverage
condition: eq(variables['Build.Reason'], 'Manual')
dependsOn:
- Validate
jobs:
- job: GetCodeCoverage
displayName: Get Code Coverage from Delta Changes
pool:
name: IblPool
steps:
- task: 6d15af64-176c-496d-b583-fd2ae21d4df4@1
inputs:
repository: self
fetchDepth: 0
persistCredentials: true
clean: true
- task: DownloadSecureFile@1
displayName: 'Download server.key'
inputs:
secureFile: 'prod.key'
downloadPath: '$(Agent.TempDirectory)'
retryCount: 3
cleanDestinationFolder: true
- task: CmdLine@2
displayName: 'Authorize sandbox for code coverage'
inputs:
script: |
sfdx force:auth:jwt:grant -i
3MVG9t54FAeH5Yn0RtZfHYLfd.Qm7tcyqOuwiPM6PuhATgckymH5SuHYaqoP9xOdbwjON7ASHhdc8V4HahZ
nX -f $(Agent.TempDirectory)/prod.key --username mangali.rambabu@indusind.com -r
https://indusindbank.my.salesforce.com -a Rambabu_PROD
- task: CmdLine@2
displayName: 'Check if prod.key exists'
inputs:
script: |
if exist "$(Agent.TempDirectory)\prod.key" (
echo "prod.key exists."
) else (
echo "prod.key does not exist."
exit 1
)
- task: CmdLine@2
displayName: 'Run Apex Tests for delta changes'
inputs:
script: |
mkdir test-results
for /f "tokens=*" %%i in ('sfdx force:apex:test:run --testlevel
RunLocalTests --codecoverage --resultformat json --wait 10 --outputdir test-results
--json') do (
set "TEST_RUN_ID=%%i"
set "TEST_RUN_ID=!TEST_RUN_ID:~14,36!" # Adjust this slice based on
the actual output structure
)
echo Test Run ID: %TEST_RUN_ID%
echo Waiting for tests to complete...
:waitLoop
for /f "tokens=*" %%j in ('sfdx force:apex:test:report -i %TEST_RUN_ID%
--json') do (
set "STATUS=%%j"
echo Current status: %STATUS%
if "%STATUS%"=="Completed" (
goto :endWait
)
timeout /t 10
goto waitLoop
)
:endWait
echo Tests completed.
- task: CmdLine@2
displayName: 'Display Code Coverage Results'
inputs:
script: |
echo "Code Coverage Results:"
type test-results/test-result.txt