Question
Accenture
US
Last activity: 5 Apr 2019 16:12 EDT
Running RAP Export and Import Asynchronously via Jenkins
Hello,
I have created a Jenkins project to export and import larger product files asynchronously via Jenkins.
I have attached the Jenkins-build.xml file that I used to set both import.async and export.async to true:
<entry key="${env.SystemName}.export.async" value="true"/>
...
...
<entry key="${env.SystemName}.import.async" value="true"/>
After performing an Ant Build Step with this Jenkins-build.xml file, I run an "Execute shell" step to run the export:
$PEGA_HOME/scripts/utils/prpcServiceUtils.sh \
export \
--connPropFile \
$WORKSPACE/${SystemName}_export.properties \
--artifactsDir $WORKSPACE \
--requestTimeOut 3600
and from there, I check the status of the job with the following "Execute shell" step to wait until the export has succeeded:
Hello,
I have created a Jenkins project to export and import larger product files asynchronously via Jenkins.
I have attached the Jenkins-build.xml file that I used to set both import.async and export.async to true:
<entry key="${env.SystemName}.export.async" value="true"/>
...
...
<entry key="${env.SystemName}.import.async" value="true"/>
After performing an Ant Build Step with this Jenkins-build.xml file, I run an "Execute shell" step to run the export:
$PEGA_HOME/scripts/utils/prpcServiceUtils.sh \
export \
--connPropFile \
$WORKSPACE/${SystemName}_export.properties \
--artifactsDir $WORKSPACE \
--requestTimeOut 3600
and from there, I check the status of the job with the following "Execute shell" step to wait until the export has succeeded:
JOBIDFILE=$(find $WORKSPACE -type f \
-name "jobIds.txt" \
-printf '%T+ %p\n' | \
grep EXPORT | \
sort -r | \
head -1 | \
awk '{print $2}')
$PEGA_HOME/scripts/utils/prpcServiceUtils.sh \
getStatus \
--jobIdFile $JOBIDFILE \
--connPropFile \
$WORKSPACE/${SystemName}_export.properties \
--artifactsDir $WORKSPACE > \
$WORKSPACE/${SystemName}_getstatus.output.txt
# Save the Status of the Export returned from
#the 'getStatus' command
EXPORTSTATUS=$(sed -nr \
's/^.*Status\s*:\s(\S*)\s*/\1/p' \
$WORKSPACE/${SystemName}_getstatus.output.txt)
# Continue to check Status until the Export Succeeds
while [[ "$EXPORTSTATUS" != "SUCCESS" ]]
do
# Check every 10 seconds
sleep 10
$PEGA_HOME/scripts/utils/prpcServiceUtils.sh \
getStatus \
--jobIdFile $JOBIDFILE \
--connPropFile \
$WORKSPACE/${SystemName}_export.properties \
--artifactsDir $WORKSPACE > \
$WORKSPACE/${SystemName}_getstatus.output.txt
EXPORTSTATUS=$(sed -nr \
's/^.*Status\s*:\s(\S*)\s*/\1/p' \
$WORKSPACE/${SystemName}_getstatus.output.txt)
done
# If the Status succeeds, move the Export file to the
# $WORKSPACE/destination directory
# (where the import is looking for it)
if [ $EXPORTSTATUS == "SUCCESS" ]; then
PRODUCTFILE=$(find $WORKSPACE -type f \
-name "$productName$productVersion.zip")
# If the destination directory does not exist
# create it
if [ ! -d "$WORKSPACE/destination" ]; then
mkdir $WORKSPACE/destination
fi
mv $PRODUCTFILE $WORKSPACE/destination/
fi
Everything works fine, but I was wondering if there is a cleaner way for me to obtain the location of the jobIds.txt file or the status returned from the getStatus command instead of parsing them out with these two variables that I created ($JOBIDFILE and $EXPORTSTATUS):
JOBIDFILE=$(find $WORKSPACE -type f \
-name "jobIds.txt" \
-printf '%T+ %p\n' | \
grep EXPORT | \
sort -r | \
head -1 | \
awk '{print $2}')
$PEGA_HOME/scripts/utils/prpcServiceUtils.sh \
getStatus \
--jobIdFile $JOBIDFILE \
--connPropFile \
$WORKSPACE/${SystemName}_export.properties \
--artifactsDir $WORKSPACE > \
$WORKSPACE/${SystemName}_getstatus.output.txt
# Save the Status of the Export
# returned from the 'getStatus' command
EXPORTSTATUS=$(sed -nr \
's/^.*Status\s*:\s(\S*)\s*/\1/p' \
$WORKSPACE/${SystemName}_getstatus.output.txt)
I haven't found clear steps on how to perform these processes in Jenkins asynchronously, but I would be more than happy to make a more complete post.