Skip to content

Instantly share code, notes, and snippets.

@edm00se
Last active March 25, 2016 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edm00se/d30002d54e07fe13f2ae to your computer and use it in GitHub Desktop.
Save edm00se/d30002d54e07fe13f2ae to your computer and use it in GitHub Desktop.
Jenkins CI build of a large NSF from ODP in git repo, at given tag/commit.
# fetch tags, then checkout the specified tag, by Jenkins param env var
git fetch
git checkout $TAGNAME
# check for whether package.json and Gruntfile.js exist, if not, copy them in
if [[ ! -f package.json ]]; then
echo "package.json does not exist, copying one in"
cp /c/xsltproc4domino/boilerplate_package.json ./package.json
fi
if [[ ! -f Gruntfile.js ]]; then
echo "Gruntfile.js does not exist, copying one in"
cp /c/xsltproc4domino/boilerplate_Gruntfile.js ./Gruntfile.js
fi
# if you need to change the ODP path (e.g.- NSF instead of ODP), do so
sed -i -e 's/\.\/ODP\//\.\/NSF\//g' ./Gruntfile.js
# run npm install and Grunt, for the appropriate xsltproc transform
npm install
grunt
"C:\Program Files (x86)\XPageDeveloper\NotesClientKiller\Notes Client Killer.exe" -forceandclean
$projName="myProj"
$buildTag=$env:TAGNAME
$buildTag = $buildTag -replace '\.',''
# avoid use of hyphens, underscores, or periods/decimals, they shouldn't matter but seem to get in the way
$buildNum=$env:BUILD_NUMBER
$buildName=$projName+'BuildNum'+$buildNum
$workspace=$env:WORKSPACE
Clear-Content HEADLESS0.log
$args = '-RPARAMS -console -vmargs -Dcom.ibm.designer.cmd="true,true,'+$buildName+'.nsf,importandbuild,'+$workspace+'\NSF\.project,'+$buildName+'.nsf"'
Write-Host $args
$p = Start-Process designer -ArgumentList $args
$target = 'notes2'
$process = Get-Process | Where-Object {$_.ProcessName -eq $target}
do {
Get-Content headless0.log -Wait | Select-String "closing designer" | %{ write-host Found $_; break}
} until($process.HasExited)
cd "$WORKSPACE"
if [[ -f "HEADLESS0.log" ]]; then
echo "'HEADLESS0.log' Exists"
if grep -qi "job error" $FILE; then
# code if found
exit 1
else
# code if not found
exit 0
fi
else
echo "'HEADLESS0.log' Does Not Exist"
exit 1
fi
if [[ ! -f "sonar-project.properties" ]]; then
echo "sonar.projectKey=my:proj" > sonar-project.properties
echo "sonar.projectName=myProj" >> sonar-project.properties
echo "sonar.projectVersion=myProj-$TAGNAME-BuildNum$BUILD_NUMBER" >> sonar-project.properties
echo "sonar.sources=ODP\\Code\\Java\\com" >> sonar-project.properties
echo "sonar.sourceEncoding=UTF-8" >> sonar-project.properties
fi
sonar-runner

Requirements

  • Windows OS w/
    • Domino Designer installed for headless DDE builds
    • Notes SSO (so no pw prompt)
    • DESIGNER_AUTO_ENABLED=true set in notes.ini
    • at same FP/version as server environments
    • any dependent OSGi plugins for DDE installed
    • any dependent JARs from server/apps installed to <installDir>/jvm/lib/ext/
    • (optional) Notes Client Killer installed
  • Jenkins CI installed as an "app"
    • to run as logged in user (does not happen if done as a Windows service, sadly)
    • configured to allow interacting with the desktop (may be service only)
    • task will contain (by my implementation) 4 steps (see other files)
      1. (optional*, unless large NSF w/ build issues) xsltproc4domino (abbreviated DORA) to ensure a clean ODP import by headless DDE
      2. (optional) Notes Client Killer (helps, in case Jenkins task +/- headless DDE gets hung; at a minimum, have a separate Jenkins task to call the client killer)
      3. PowerShell to execute the headless DDE build
      4. scan the HEADLESS0.log for whether to mark the task a failure (Jenkins had mis-reported "SUCCESS" when the headless DDE call failed to build a usable NSF)
      5. (optional) SonarQube analysis (previously covered)
  • git repository access to the project(s) in question, at least visible to the Jenkins instance
  • (optional) a SonarQube (server) environment set up, scanner installed and config'd correctly for shell use w/ Jenkins

Recommended (optional):

  • Color ANSI plugin (to make better console output for Jenkins)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment