Shared Library Pipeline Steps
Being a pipeline from a shared library this pipeline must extend a call
method. This pipeline expects a Map
object, containing the parameters to be passed to the pipeline from the job configuration and trigger.
Once this pipeline has been triggered, the job will execute the following steps.
Execute its call
method, within which it will
def call(Map pipelineParams)
{
node
{
- Execute its
initialize
method to read configuration files and instantiate objects of helper classes- Reading the mail list configuration file and build in internal map of ISPW owner IDs and corresponding email addresses
PipelineConfig
containing global parameter values that:- passed by the job configuration/trigger and are pipeline/execution specific
- not pipeline or execution specific, like server URLs. These parameters will be read from external configuration files
GitHelper
serving as a wrapper for a set of interactions with Git/GitHubIspwHelper
serving as a wrapper for use by the ISPW plugins' methodsTttHelper
serving as a wrapper for use by the TTT plugin's and Code Coverage plugin's methodsSonarHelper
serving as a wrapper for use by the Sonar plugins' methodsXlrHelper
serving as a wrapper for use by the XL Release plugin
initialize(pipelineParams)
- Use the
downloadSources
method of classIspwHelper
to download all COBOL sources and COBOL copybooks from ISPW (the mainframe) that are part of the set triggering this specific pipeline execution
stage("Retrieve Mainframe Code")
{
ispwHelper.downloadSources()
}
- Use the
checkout
method of thegitHelper
class to clone the Git repository for the ISPW application.
stage("Execute Unit Tests")
{
def gitUrlFullPath = "${pConfig.gitUrl}/${pConfig.gitTttRepo}"
gitHelper.checkout(gitUrlFullPath, pConfig.gitBranch, pConfig.gitCredentials, pConfig.tttFolder)
- Initialize the
TttHelper
instance, clean up statistics in the Code Coverage repository from the previous build (job execution), loop through the downloaded Topaz for Total Test scenarios, and pass the results to JUnit (within Jenkins) using the methodsinitialize
,cleanUpCodeCoverageResults
,loopThruScenarios
, andpassResultsToJunit
of theTttHelper
class, respectively.
tttHelper.initialize()
tttHelper.cleanUpCodeCoverageResults()
tttHelper.loopThruScenarios()
tttHelper.passResultsToJunit()
}
- Use the
collectCodeCoverageResults
method of theTttHelper
class to download the code coverage metrics from the Xpediter Code Coverage repository
stage("Collect Metrics")
{
tttHelper.collectCodeCoverageResults()
}
- Not always will all required COBOL copybooks be part of an ISPW assignment or set. In order to retrieve any missing copybooks, the next stage will first use the
downloadCopyBooks
method of classispwHelper
to determine all required copybooks and download them from the mainframe
stage("Check SonarQube Quality Gate")
{
ispwHelper.downloadCopyBooks("${workspace}")
- The it will use the
scan
method of theSonarHelper
class to pass downloaded COBOL sources, the results of the unit tests, and code coverage metrics to SonarQube
sonarHelper.scan()
- And use the
sonarHelper.checkQualityGate
of thesonarHelper.checkQualityGate
class to query the resulting Sonar quality gate. If the quality gate fails, an email will be sent to the owner of the ISPW set - notifying them about the failure of the promote and the pipeline job will be aborted.
String sonarGateResult = sonarHelper.checkQualityGate()
if (sonarGateResult != 'OK')
{
echo "Sonar quality gate failure: ${sonarGate.status}"
echo "Pipeline will be aborted and ISPW Assignment will be regressed"
mailMessageExtension = "Generated code failed the Quality gate. Review Logs and apply corrections as indicated."
currentBuild.result = "FAILURE"
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT',
replyTo: '$DEFAULT_REPLYTO',
to: "${pConfig.mailRecipient}"
error "Exiting Pipeline"
}
- Otherwise a mail message will be prepared, informing the owner of the success.
else
{
mailMessageExtension = "Generated code passed the Quality gate. XL Release will be started."
}
}
- If the quality gate passes an XL Release template will be triggered - using
trggerRelease
method of theXlrHelper
class.
stage("Start release in XL Release")
{
xlrHelper.triggerRelease()
}
- An email will be sent to the owner of the ISPW set - notifying them about the success of the promote
stage("Send Mail")
{
// Send Standard Email
emailext subject: '$DEFAULT_SUBJECT',
body: '$DEFAULT_CONTENT \n' + mailMessageExtension,
replyTo: '$DEFAULT_REPLYTO',
to: "${pConfig.mailRecipient}"
}
}
}