Skip to content

Commit a1fd862

Browse files
committed
Added DB2 Bind Package Sample
1 parent 18b106d commit a1fd862

File tree

6 files changed

+592
-472
lines changed

6 files changed

+592
-472
lines changed

MortgageApplication/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>MortgageApplication</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

MortgageApplication/README.md

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
1-
# Mortgage Application Sample
2-
The Mortgage Application sample is comprised of a COBOL application and Groovy build scripts that use IBM Dependency Based Build (DBB) APIs to build the application for execution on z/OS. The sample demonstrates the following build functions:
3-
* How to use property files for build configuration
4-
* How to handle build script command line arguments
5-
* How to organize build scripts into main and called scripts for building specific source file types
6-
* How to create new datasets, copy zFS files to datasets, invoke z/OS compilers and linkers, copy SYSPRINT datasets to zFS as log files
7-
* How to scan source files to gather dependency data and store in the DBB repository for later dependency resolution
8-
* How to generate a build report that contains a summary of source files built
9-
* How to store build results in the DBB repository for later retrieval
10-
* How to perform incremental builds by identifying changed files since the last build and discover impacted programs that need rebuilding
11-
* How to run a post build process to create an UrbanCode Deploy shiplist from a saved DBB build report
12-
13-
## Configuring the Mortgage Application Sample for your system
14-
All of the build files are located in the `MortgageApplication/build` folder. The folder contains two properties files that need to be edited before the Mortgage Application build scripts can run successfully. The files contain instructions on what needs to be set.
15-
* datasets.properties - Contains build properties for Partition Data Sets (PDS) used by Mortgage Application sample scripts
16-
* build.properties - Contains default sandbox properties used by Mortgage Application build scripts. Many of these properties can be overridden using command line arguments when running the Groovy build script (see the comment block in build.groovy)
17-
18-
## Build Script Organization
19-
The Mortgage Application build folder contains three main build scripts and six called build scripts. The Groovy scripts are extensively commented and can be used to jump start writing build scripts for new applications.
20-
21-
### build.groovy
22-
This is the main build script for building the Mortgage Application. It performs build process initiation, scans the source files for dependency data, invokes called build scripts to build specific file types, generates a build report and saves build results to the DBB web application repository. The five called build scripts are
23-
* BMSProcessing.groovy - Script that demonstrates how to build CICS BMS maps
24-
* Compile.groovy - Script that demonstrates how to just compile a COBOL program to produce a object deck
25-
* LinkEdit.groovy - Script that demonstrates how to link-edit object decks to produce a load module
26-
* CobolCompile.groovy - Script that demonstrates how to compile and link-edit COBOL programs in one script
27-
* MFSGENUtiltiy.groovy - Script that demonstrates how to build IMS Message Format Service (MFS) files
28-
* Tools.groovy - Script that provides common utility Groovy methods used by the build scripts.
29-
30-
The easiest way to invoke the build.groovy file from the Unix System Services (USS) command line is to use the build.sh shell script provided in the MortgageApplication/build folder. **NOTE: The build.sh shell script may need to be edited if the DBB installation is not located at /usr/lpp/IBM/dbb .** Invoking `build.sh` with no arguments will result in all the files listed in `MortgageApplication/build/files.txt` being scanned and built. Invoking `build.sh --help` will display the command line arguments that are supported by build.groovy.
31-
32-
The build.groovy script can also be invoked from a Jenkins process server via a remote agent running on USS. It is important to note that when invoking Groovy scripts that use DBB APIs either by using Groovy directly or a tool like Jenkins that invokes Groovy, you will need to set both the Java classpath and the Java native library path to include the DBB toolkit lib directory. Example:
33-
```
34-
Class path : /usr/lpp/IBM/dbb/lib/*
35-
Java opts : -Djava.library.path=/usr/lpp/IBM/dbb
36-
```
37-
38-
### impacts.groovy
39-
The impacts.groovy script is an optional pre-build script that runs before build.groovy runs. When provided with the current build's Git hash, it will retrieve the last successful build's Git hash from the DBB web application repository and execute a `git diff` command to identify which files have changed since the last build. It then runs an impact analysis for each changed file to see what programs will need to be rebuilt. Finally it generates a buildList.txt file that can be passed to build.groovy to build just the programs that need to be built.
40-
41-
In order to use impacts.groovy with build.groovy to changes need to be made to the build.groovy argument list:
42-
* add option `--buildHash <hash>` where <hash> is the Git commit hash for the current build
43-
* use `<workDir>/buildList.txt` as the build list file (last argument) where <workDir> is the directory where the buildList.txt was generated from running impacts.groovy.
44-
45-
Since impacts.groovy requires the current Git build hash as an argument, no shell script has been provided to run the script as it is assumed that it will be run by a build processing server like Jenkins. The Jenkins Git client plugin sets the current build Git hash in environment variable $GIT_COMMIT.
46-
47-
### deploy.groovy
48-
The deploy.groovy script is an optional post-build script that runs after build.groovy runs. The script parses the buildReport.json file generated by the build.groovy script at the end of the build. From the build report it generates an UrbanCode Deploy (UCD) shiplist. It then runs a UCD buztool command to create a UCD z/OS component version for deployment.
49-
50-
51-
52-
1+
# Mortgage Application Sample
2+
The Mortgage Application sample is comprised of a COBOL application and Groovy build scripts that use IBM Dependency Based Build (DBB) APIs to build the application for execution on z/OS. The sample demonstrates the following build functions:
3+
* How to use property files for build configuration
4+
* How to handle build script command line arguments
5+
* How to organize build scripts into main and called scripts for building specific source file types
6+
* How to create new datasets, copy zFS files to datasets, invoke z/OS compilers and linkers, copy SYSPRINT datasets to zFS as log files
7+
* How to scan source files to gather dependency data and store in the DBB repository for later dependency resolution
8+
* How to generate a build report that contains a summary of source files built
9+
* How to store build results in the DBB repository for later retrieval
10+
* How to perform incremental builds by identifying changed files since the last build and discover impacted programs that need rebuilding
11+
* How to run a post build process to create an UrbanCode Deploy shiplist from a saved DBB build report
12+
* How to build a DB2 application package for SQL programs.
13+
14+
## Configuring the Mortgage Application Sample for your system
15+
All of the build files are located in the `MortgageApplication/build` folder. The folder contains two properties files that need to be edited before the Mortgage Application build scripts can run successfully. The files contain instructions on what needs to be set.
16+
* datasets.properties - Contains build properties for Partition Data Sets (PDS) used by Mortgage Application sample scripts
17+
* build.properties - Contains default sandbox properties used by Mortgage Application build scripts. Many of these properties can be overridden using command line arguments when running the Groovy build script (see the comment block in build.groovy)
18+
19+
## Build Script Organization
20+
The Mortgage Application build folder contains three main build scripts and six called build scripts. The Groovy scripts are extensively commented and can be used to jump start writing build scripts for new applications.
21+
22+
### build.groovy
23+
This is the main build script for building the Mortgage Application. It performs build process initiation, scans the source files for dependency data, invokes called build scripts to build specific file types, generates a build report and saves build results to the DBB web application repository. The five called build scripts are
24+
* BMSProcessing.groovy - Script that demonstrates how to build CICS BMS maps
25+
* Compile.groovy - Script that demonstrates how to just compile a COBOL program to produce a object deck
26+
* LinkEdit.groovy - Script that demonstrates how to link-edit object decks to produce a load module
27+
* CobolCompile.groovy - Script that demonstrates how to compile and link-edit COBOL programs in one script
28+
* BindPackage.groovy - Script that demonstrates how to build a DB2 application package for SQL programs. Called from CobolCompile.groovy.
29+
* MFSGENUtiltiy.groovy - Script that demonstrates how to build IMS Message Format Service (MFS) files
30+
* Tools.groovy - Script that provides common utility Groovy methods used by the build scripts.
31+
32+
The easiest way to invoke the build.groovy file from the Unix System Services (USS) command line is to use the build.sh shell script provided in the MortgageApplication/build folder. **NOTE: The build.sh shell script may need to be edited if the DBB installation is not located at /usr/lpp/IBM/dbb .** Invoking `build.sh` with no arguments will result in all the files listed in `MortgageApplication/build/files.txt` being scanned and built. Invoking `build.sh --help` will display the command line arguments that are supported by build.groovy.
33+
34+
The build.groovy script can also be invoked from a Jenkins process server via a remote agent running on USS. It is important to note that when invoking Groovy scripts that use DBB APIs either by using Groovy directly or a tool like Jenkins that invokes Groovy, you will need to set both the Java classpath and the Java native library path to include the DBB toolkit lib directory. Example:
35+
```
36+
Class path : /usr/lpp/IBM/dbb/lib/*
37+
Java opts : -Djava.library.path=/usr/lpp/IBM/dbb
38+
```
39+
40+
### impacts.groovy
41+
The impacts.groovy script is an optional pre-build script that runs before build.groovy runs. When provided with the current build's Git hash, it will retrieve the last successful build's Git hash from the DBB web application repository and execute a `git diff` command to identify which files have changed since the last build. It then runs an impact analysis for each changed file to see what programs will need to be rebuilt. Finally it generates a buildList.txt file that can be passed to build.groovy to build just the programs that need to be built.
42+
43+
In order to use impacts.groovy with build.groovy to changes need to be made to the build.groovy argument list:
44+
* add option `--buildHash <hash>` where <hash> is the Git commit hash for the current build
45+
* use `<workDir>/buildList.txt` as the build list file (last argument) where <workDir> is the directory where the buildList.txt was generated from running impacts.groovy.
46+
47+
Since impacts.groovy requires the current Git build hash as an argument, no shell script has been provided to run the script as it is assumed that it will be run by a build processing server like Jenkins. The Jenkins Git client plugin sets the current build Git hash in environment variable $GIT_COMMIT.
48+
49+
### deploy.groovy
50+
The deploy.groovy script is an optional post-build script that runs after build.groovy runs. The script parses the buildReport.json file generated by the build.groovy script at the end of the build. From the build report it generates an UrbanCode Deploy (UCD) shiplist. It then runs a UCD buztool command to create a UCD z/OS component version for deployment.
51+
52+
53+
54+
5355

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import com.ibm.dbb.build.*
2+
import com.ibm.dbb.repository.*
3+
import com.ibm.dbb.dependency.*
4+
5+
/**
6+
* This script builds a DB2 application package for SQL programs in the MortgageApplication sample. It is
7+
* called by the CobolCompile.groovy script. It requires that the properties in MortgageApplication/build/bind.properties
8+
* be set to the correct values for your system.
9+
*
10+
* **NOTE - This script contains syntax that requires PTF UI54779 be applied to the DBB toolkit.
11+
*/
12+
13+
// receive passed arguments
14+
def file = args[0]
15+
println("* Binding $file using ${this.class.getName()}.groovy script")
16+
17+
// define local properties
18+
def properties = BuildProperties.getInstance()
19+
def dbrmPDS = "${properties.hlq}.DBRM"
20+
def clistPDS = "${properties.hlq}.CLIST"
21+
def cmdscpDS = "${properties.hlq}.ISPFGWY.EXEC"
22+
def member = CopyToPDS.createMemberName(file)
23+
def logFile = new File("${properties.workDir}/${member}_bind.log")
24+
def srcOptions = "cyl space(1,1) lrecl(80) dsorg(PO) recfm(F,B) dsntype(library) msg(1)"
25+
26+
// create BIND CLIST if necessary
27+
def clist = new File("${properties.workDir}/bind.clist")
28+
if (!clist.exists()) {
29+
clist << """PROC 6 SUBSYS COLLID MEMBER LIB OWNER QUAL
30+
DSN SYSTEM(&SUBSYS)
31+
BIND PACKAGE(&COLLID) +
32+
MEMBER(&MEMBER) +
33+
LIBRARY('&LIB') +
34+
OWNER(&OWNER) +
35+
QUALIFIER(&QUAL) +
36+
ACTION(REPLACE) +
37+
ISOLATION(CS)
38+
END
39+
EXIT CODE(&LASTCC)
40+
"""
41+
42+
// create CLIST PDS if necessary
43+
new CreatePDS().dataset(clistPDS).options(srcOptions).create()
44+
45+
// copy CLIST to PDS
46+
println("Copying ${properties.workDir}/bind.clist to $clistPDS(BIND)")
47+
new CopyToPDS().file(clist).dataset(clistPDS).member("BIND").execute()
48+
}
49+
50+
// bind the build file
51+
println("Executing CLIST to bind program $file")
52+
53+
// define TSOExec to run the bind clist
54+
def bind = new TSOExec().file(file)
55+
.command("exec '$clistPDS(BIND)'")
56+
.options("'${properties.SUBSYS} ${properties.COLLID} $member $dbrmPDS ${properties.OWNER} ${properties.QUAL}'")
57+
.logFile(logFile)
58+
.confDir(properties.CONFDIR)
59+
.keepCommandScript(true)
60+
bind.dd(new DDStatement().name("CMDSCP").dsn(cmdscpDS).options("shr"))
61+
62+
// execute the bind clist
63+
def rc = bind.execute()
64+
65+
// add the DB2 BIND status to the build result
66+
File scriptFile = new File("$properties.sourceDir/MortgageApplication/build/Tools.groovy")
67+
Class groovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(scriptFile)
68+
GroovyObject tools = (GroovyObject) groovyClass.newInstance()
69+
tools.updateBuildResult(file:"$file", rc:rc, maxRC:0, log:logFile)

0 commit comments

Comments
 (0)