diff --git a/scripts/job/ovs-git.sh b/scripts/job/ovs-git.sh new file mode 100644 index 0000000..0214639 --- /dev/null +++ b/scripts/job/ovs-git.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +function Check-LastRanFile { + lastranfile="$WORKSPACE/lastrancommit.txt" + if [ ! -e $lastranfile ]; then + echo "LastRanFile doesn't exist. Creating it." + git -C $WORKSPACE/ovs rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt + echo "Starting first job for OVS unit tests" + firstcommit=$(cat $WORKSPACE/lastrancommit.txt) + curl -X POST "http://{jenkins_user}:{jenkins_pass}@{jenkins_ip}:8080/job/ovs-build-job/buildWithParameters?token={token}&commitid=$firstcommit" + echo "Job for first commitID $firstcommit started" + fi +} + +function Get-GitLog { + currentcommit=$(cat $WORKSPACE/lastrancommit.txt) + commitlog=$(git -C $WORKSPACE/ovs rev-list $currentcommit...HEAD) + if [ ! "$commitlog" ]; then + echo "There are no new commits to OVS master. Existing Job." + exit 0 + fi + echo "$commitlog" | tee $WORKSPACE/gitlog.txt + head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt +} + +function Start-OVSBuildJob { + while read line + do + echo "Starting job for commitID $line" + curl -X POST "http://{jenkins_user}:{jenkins_pass}@{jenkins_ip}:8080/job/ovs-build-job/buildWithParameters?token={token}&commitid=$line" + echo "Job for commitID $line started" + done < $WORKSPACE/gitlog.txt +} + +echo "Getting commit ID's and writing them to $WORKSPACE/gitlog.txt" + +Check-LastRanFile + +Get-GitLog + +Start-OVSBuildJob \ No newline at end of file diff --git a/scripts/unit-tests/config.ps1 b/scripts/unit-tests/config.ps1 new file mode 100644 index 0000000..6b73261 --- /dev/null +++ b/scripts/unit-tests/config.ps1 @@ -0,0 +1,55 @@ +# Environment variables +$ENV:PATH = "C:\Perl64\bin;$ENV:PATH" +$ENV:PATH += ";${ENV:ProgramFiles}\7-Zip" +$ENV:PATH += ";${ENV:ProgramFiles}\Git\bin" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\CMake\bin" +$ENV:PATH += ";C:\Python27" +$ENV:PATH += ";C:\Python3" +$ENV:PATH += ";${ENV:ProgramFiles(x86)}\PuTTY" +$ENV:PATH = "C:\mingw\msys\1.0\bin;$ENV:PATH" + +# Jenkins Job Variables +$commitID = $env:commitid +$unitStatus = $env:unitStatus +$makeStatus = $env:makeStatus +$workspace = $env:WORKSPACE + +# OVS git URL +$OVS_URL = "https://github.com/openvswitch/ovs.git" + +# Path variables +$basePath = "C:\OpenStack\OpenvSwitch" +$buildDir = "$basePath\Build" +$commitDir = "$buildDir\$commitID" +$outputPath = "$commitDir\bin" +$commitmsiDir = "$basePath\installer\$commitID" +$localLogs = "$basePath\logs" +$commitlogDir = "$localLogs\$commitID" +$outputSymbolsPath = "$commitDir\symbols" +#automake already appends \lib\ to the pthread library +$winPthreadLibDir = "$basePath\pthread" +$pthreadDir = $winPthreadLibDir.Replace("\", "/") +#Git clone Dir +$gitcloneDir = "$commitDir\ovs" + +# Visual Studio version +$vsVersion = "12.0" +$platform = "x86_amd64" + +# Remote Log Server Variables +$remoteServer = "10.20.1.14" +$remoteUser = "logs" +$remoteKey = "C:\ovs-ci\scripts\unit-tests\ssh\norman.ppk" +$remotelogDir = "/srv/logs/unit-tests/ovs" +$remotemsiDir = "/srv/dl/ovs" +$remotelogdirPath = "$remotelogDir/$commitID" +$remotemsidirPath = "$remotemsiDir/$commitID" + +# Email Job Variables +$smtpServer = "192.168.1.3" +$from = "microsoft_ovs_ci@microsoft.com" +$to = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com","ovs-build@openvswitch.org" +$msito = "aserdean@cloudbasesolutions.com","ociuhandu@cloudbasesolutions.com","mgheorghe@cloudbasesolutions.com" +$commitLink = "https://github.com/openvswitch/ovs/commit/$commitID" +$privatelogLink = "http://$remoteServer/ovs/unit-tests/$commitID" +$publiclogLink = "http://64.119.130.115/ovs/unit-tests/$commitID" diff --git a/scripts/unit-tests/ovs-build.ps1 b/scripts/unit-tests/ovs-build.ps1 new file mode 100644 index 0000000..5f4a38b --- /dev/null +++ b/scripts/unit-tests/ovs-build.ps1 @@ -0,0 +1,90 @@ +Param( +) +$ErrorActionPreference = "Stop" + +# Source the config and utils scripts. +$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition +. "$scriptPath\config.ps1" +. "$scriptPath\utils.ps1" + +CheckLocalPaths +# Create the log paths on the remote log server +CreateRemotePaths $remotelogdirPath + +pushd $commitDir +GitClonePull $gitcloneDir $OVS_URL +popd +pushd $gitcloneDir +Set-GitCommidID $commitID +Set-commitInfo + +$msysCwd = "/" + $pwd.path.Replace("\", "/").Replace(":", "") + +# Make Visual Studio Paths available to msys. +Set-VCVars $vsVersion $platform +# This must be the Visual Studio version of link.exe, not MinGW +$vsLink = $(Get-Command link.exe).path +$vsLinkPath = $vsLink.Replace("\", "/").Replace(":", "") + +$makeScriptPath = Set-MakeScript +Get-Content $makeScriptPath +write-host "Running make on OVS commit $commitid" +&bash.exe $makeScriptPath + if ($LastExitCode) { + copy-item -Force "$gitcloneDir\makeoutput.log" "$commitlogDir\makeoutput.log" + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "makeStatus=ERROR" + popd + Cleanup + throw "make.sh failed" + } + else { + write-host "Finished compiling. Moving on..." + } + +$unitScriptPath = Set-UnitScript +Get-Content $unitScriptPath +write-host "Running unit tests!" +&bash.exe $unitScriptPath | Tee-Object -FilePath "$commitlogDir\unitsoutput.log" + if ($LastExitCode) { + Copy-LocalLogs + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "unitStatus=FAILED" + popd + Cleanup + throw "Unit tests failed. The logs have been saved." + } + else { + write-host "unit tests succeded. Moving on" + Copy-LocalLogs + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\*" $remotelogdirPath + New-Item -Type file -Force -Path "$workspace\params.txt" -Value "unitStatus=PASSED" + } + +$msiScriptPath = Set-MsiScript +Get-Content $msiScriptPath +write-host "Building OVS MSI." +&bash.exe $msiScriptPath | Tee-Object -FilePath "$commitlogDir\msioutput.log" + if ($LastExitCode) { + cd $buildDir + CompressLogs "$commitlogDir" + Copy-RemoteLogs "$commitlogDir\msioutput.log.gz" $remotelogdirPath + popd + Cleanup + throw "Failed to create OVS msi." + } + else { + write-host "OVS msi created." + # Create the msi remote log paths + CreateRemotePaths $remotemsidirPath + CompressLogs "$commitlogDir" + Copy-LocalMsi + Copy-RemoteLogs "$commitlogDir\msioutput.log.gz" $remotelogdirPath + Copy-RemoteMSI "$gitcloneDir\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" $remotemsidirPath + Copy-RemoteMSI "$gitcloneDir\datapath-windows\x64\Win8.1Debug\package.cer" $remotemsidirPath + popd + Cleanup + } diff --git a/scripts/unit-tests/ovs-email.ps1 b/scripts/unit-tests/ovs-email.ps1 new file mode 100644 index 0000000..880e6f1 --- /dev/null +++ b/scripts/unit-tests/ovs-email.ps1 @@ -0,0 +1,22 @@ +# Source the config and utils scripts. +$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition +. "$scriptPath\config.ps1" +. "$scriptPath\utils.ps1" + + +$messageUri = "$privatelogLink/commitmessage.txt.gz" +$messageOutFile = "$localLogs\message-$commitID.txt" +write-host "connecting to $messageUri" +ExecRetry {Invoke-WebRequest -Uri $messageUri -OutFile $messageOutFile} +$commitMessage = Get-Content $messageOutFile -Raw + +if ($makeStatus) { + write-host "Sending Unit Tests E-mail for $commitID with status $unitStatus" + Send-Email $from $msito $unitStatus $commitLink $publiclogLink +} +if ($unitStatus) { + write-host "Sending Unit Tests E-mail for $commitID with status $unitStatus" + Send-Email $from $to $unitStatus $commitLink $publiclogLink +} + +Remove-Item -Force -Path $messageOutFile \ No newline at end of file diff --git a/scripts/unit-tests/ovs-req.ps1 b/scripts/unit-tests/ovs-req.ps1 new file mode 100644 index 0000000..f0d95d8 --- /dev/null +++ b/scripts/unit-tests/ovs-req.ps1 @@ -0,0 +1,110 @@ +# Make directory structure +$redistDir = "C:\Openstack\OpenvSwitch\Redist\" +if (Test-Path $redistDir) { + Remove-Item -Recurse -Force $redistDir + } +New-Item -ItemType directory -Path $redistDir + +# Download installers +Invoke-WebRequest -Uri "http://www.7-zip.org/a/7z1602-x64.msi" -OutFile "$redistDir\7zip-x64.msi" +Invoke-WebRequest -Uri "https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/Git-2.8.3-64-bit.exe" -OutFile "$redistDir\git-x64.exe" +Invoke-WebRequest -Uri "https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.msi" -OutFile "$redistDir\cmake.msi" +Invoke-WebRequest -Uri "https://wix.codeplex.com/downloads/get/1540240" -OutFile "$redistDir\wix310.exe" +Invoke-WebRequest -Uri "http://freefr.dl.sourceforge.net/project/mingw/Installer/mingw-get/mingw-get-0.6.2-beta-20131004-1/mingw-get-0.6.2-mingw32-beta-20131004-1-bin.zip" -OutFile "$redistDir\msys.zip" +Invoke-WebRequest -Uri "https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi" -OutFile "$redistDir\python-2.7.1.amd64.msi" +Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.6.0/python-3.6.0-embed-amd64.zip" -OutFile "$redistDir\python-3.6.0.amd64.zip" +Invoke-WebRequest -Uri "https://download.microsoft.com/download/9/6/4/96442E58-C65C-4122-A956-CCA83EECCD03/wdexpress_full.exe" -OutFile "$redistDir\wdexpress_full.exe" +Invoke-WebRequest -Uri "https://download.microsoft.com/download/0/8/C/08C7497F-8551-4054-97DE-60C0E510D97A/wdk/wdksetup.exe" -OutFile "$redistDir\wdksetup.exe" +Invoke-WebRequest -Uri "https://netix.dl.sourceforge.net/project/pthreads4w/pthreads-w32-2-9-1-release.zip" -OutFile "$redistDir\pthreads-w32.zip" +Invoke-WebRequest -Uri "http://downloads.activestate.com/ActivePerl/releases/5.24.1.2402/ActivePerl-5.24.1.2402-MSWin32-x64-401627.exe" -OutFile "$redistDir\activeperl-x64.exe" +Invoke-WebRequest -Uri "http://download.microsoft.com/download/A/A/D/AAD1AA11-FF9A-4B3C-8601-054E89260B78/vs_community.exe" -OutFile "$redistDir\vs_community.exe" +Invoke-WebRequest -Uri "https://the.earth.li/~sgtatham/putty/0.67/x86/putty-0.67-installer.msi" -OutFile "$redistDir\putty.msi" + +# Install prerequisite +Set-Location C:\Openstack\OpenvSwitch\Redist\ + +# Install 7zip-x64 +$7zip_msi = "$redistDir\7zip-x64.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$7zip_msi" -Wait -PassThru + +# Install Git +$git_exe = "$redistDir\git-x64.exe" +Start-Process -FilePath $git_exe -ArgumentList "/SILENT","/COMPONENTS='icons,ext\reg\shellhere,assoc,assoc_sh'","/i" -Wait -PassThru + +# Install Putty +$putty_msi = "$redistDir\putty.msi" +Start-Process -FilePath $putty_msi -ArgumentList "/q" -Wait -PassThru + +# Install cmake +$cmake_msi = "$redistDir\cmake.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/q","/i","$cmake_msi" -Wait -PassThru + +# Install Python2.7 +$python_msi = "$redistDir\python-2.7.1.amd64.msi" +Start-Process -FilePath msiexec.exe -ArgumentList "/qn","/i","$python_msi" -Wait -PassThru + +# Install Python3 +$python3_zip = "$redistDir\python-3.6.0.amd64.zip" +Get-ChildItem $python3_zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\Python3"} +Rename-Item C:\Python3\python.exe python3.exe + +# Install six for python +$ENV:PATH += ";C:\Python27" +python -m pip install six +python -m pip install pypiwin32 + +# Install ActivePerl +$activeperl_exe = "$redistDir\activeperl-x64.exe" +Start-Process -FilePath $activeperl_exe -ArgumentList "/q","/i" -Wait -PassThru + +# Install Pthreads +$pthreads_zip = "$redistDir\pthreads-w32.zip" +Get-ChildItem $pthreads_zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\Openstack\OpenvSwitch\Redist\pthreads"} +Move-Item $redistDir\pthreads\Pre-built.2 C:\Openstack\OpenvSwitch\pthread +# Copy pthread.dll to system path. +Copy-Item C:\Openstack\OpenvSwitch\pthread\dll\x64\* C:\Windows + +# Install Vstudio2013 +$vs_exe = "$redistDir\vs_community.exe" +Start-Process -FilePath $vs_exe -ArgumentList "/Quiet","/Norestart" -Wait -PassThru + +# Install WDK +$wdk_exe = "$redistDir\wdksetup.exe" +Start-Process -FilePath $wdk_exe -ArgumentList "/q" -Wait -PassThru + +# Install WIX +$wix_exe = "$redistDir\wix310.exe" +Start-Process -FilePath $wix_exe -ArgumentList "/q" -Wait -PassThru + +# Install Msys +Get-ChildItem $redistDir\msys.zip | % {& "C:\Program Files\7-Zip\7z.exe" "x" $_.fullname "-oC:\mingw"} + +# Install Msys req +$ENV:PATH += ";C:\mingw\bin" + +mingw-get update + +mingw-get upgrade + +mingw-get install msys msys-coreutils + +mingw-get install msys-binutils msys-libtool msys-automake msys-autoconf msys-make msys-patch + +mingw-get upgrade msys-core-bin=1.0.17-1 + +# Mount /mingw into msys (not sure is needed at all!) +#Rename-Item C:\mingw\msys\1.0\etc\fstab.sample fstab + +# Make sure msys get the link.exe from VS12 and not the default one. +Rename-Item -Force C:\mingw\msys\1.0\bin\link.exe linkbak.exe + +# Set WinRM concurrent processes per shell +winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}' +winrm set winrm/config/winrs '@{MaxProcessesPerShell="10000"}' +winrm set winrm/config/winrs '@{MaxShellsPerUser="100"}' + +# Set power scheme to performance +powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + +# Restart Windows so that all $env variables are set. +Restart-Computer diff --git a/scripts/unit-tests/utils.ps1 b/scripts/unit-tests/utils.ps1 new file mode 100644 index 0000000..01323e2 --- /dev/null +++ b/scripts/unit-tests/utils.ps1 @@ -0,0 +1,260 @@ +function CheckCopyDir($src, $dest) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $dest + Copy-Item -Recurse $src $dest +} + + +function GitClonePull($path, $url, $branch="master") { + Write-Host "Cloning / pulling: $url" + + if (Test-Path -path $path) { + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $path + } + + # Start git clone + &git clone $url $path + if ($LastExitCode) { + throw "git clone failed" + } + + # Change branch + &git -C $path checkout $branch + if ($LastExitCode) { + throw "git checkout for branch $branch failed" + } +} + + +function Set-GitCommidID ( $commitID ) { + pushd "$gitcloneDir" + &git checkout $commitID + write-host "this is the CommitID that we are working on" + &git rev-parse HEAD + popd +} + +function Set-commitInfo { + write-host "Reading and saving commit author and message." + pushd "$gitcloneDir" + &git log -n 1 $commitID | Out-File "$localLogs\message-$commitID.txt" + Copy-Item "$localLogs\message-$commitID.txt" -Destination "$commitlogDir\commitmessage.txt" -Force + popd +} + +function Set-VCVars($version="12.0", $platform="amd64") { + pushd "$ENV:ProgramFiles (x86)\Microsoft Visual Studio $version\VC\" + try + { + cmd /c "vcvarsall.bat $platform & set" | + foreach { + if ($_ -match "=") { + $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])" + } + } + } + finally + { + popd + } +} + +function ExecRetry ($command, $maxRetryCount = 10, $retryInterval=2) { + $currErrorActionPreference = $ErrorActionPreference + $ErrorActionPreference = "Continue" + + $retryCount = 0 + while ($true) + { + try + { + & $command + break + } + catch [System.Exception] + { + $retryCount++ + if ($retryCount -ge $maxRetryCount) + { + $ErrorActionPreference = $currErrorActionPreference + throw + } + else + { + Write-Error $_.Exception + Start-Sleep $retryInterval + } + } + } + + $ErrorActionPreference = $currErrorActionPreference +} + +function ExecSSHCmd ($server, $user, $key, $cmd) { + write-host "Running ssh command $cmd on remote server $server" + echo Y | plink.exe $server -l $user -i $key $cmd +} + +function ExecSCPCmd ($server, $user, $key, $localPath, $remotePath) { + write-host "Starting copying $localPath to remote location ${server}:${remotePath}" + echo Y | pscp.exe -scp -r -i $key $localPath $user@${server}:${remotePath} +} + +function CheckLocalPaths { + New-Item -ItemType Directory -ErrorAction SilentlyContinue -Path $basePath + New-Item -ItemType Directory -ErrorAction SilentlyContinue -Path $localLogs + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitlogDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitlogDir + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $outputSymbolsPath + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $outputPath + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitmsiDir + New-Item -ItemType Directory -Force -ErrorAction SilentlyContinue -Path $commitmsiDir +} + +function CreateRemotePaths ($remotedirPath) { + $remoteCMD = "mkdir -p $remotedirPath" + ExecSSHCmd $remoteServer $remoteUser $remoteKey $remoteCMD +} + +function Copy-LocalLogs { + $testlogPath = "$commitDir\ovs\tests\testsuite.log" + $testdirPath = "$commitDir\ovs\tests\testsuite.dir" + if ((Test-Path -path $testlogPath)) { + copy-item -Force "$testlogPath" "$commitlogDir\testsuite.log" + } + else { write-host "No testsuite.log found." } + if ((Test-Path -path $testdirPath)) { + copy-item -Force -recurse "$testdirPath" "$commitlogDir\testsuite.dir" + } + else { write-host "No testsuite.dir found." } +} + +function Copy-LocalMsi { + $msiPath = "$commitDir\ovs\windows\ovs-windows-installer\bin\Release\OpenvSwitch.msi" + if ((Test-Path -path $msiPath)) { + copy-item -Force "$msiPath" "$commitmsiDir\OpenvSwitch.msi" + } + else { write-host "No msi found."} +} + +function Copy-RemoteLogs ($locallogPath, $remotelogPath) { + write-host "Started copying logs for commit ID $commitID unit tests to remote location ${server}:${remotelogPath}" + ExecSCPCmd $remoteServer $remoteUser $remoteKey $locallogPath $remotelogPath +} + +function Copy-RemoteMSI ($localmsiPath) { + write-host "Started copying generated msi for commit ID $commitID to remote location ${server}:${remotemsiPath}" + ExecSCPCmd $remoteServer $remoteUser $remoteKey $localmsiPath $remotemsiPath +} + +function CompressLogs ( $logsPath ) { + $logfiles = Get-ChildItem -File -Recurse -Path $logsPath | Where-Object { $_.Extension -ne ".gz" } + foreach ($file in $logfiles) { + $filename = $file.name + $directory = $file.DirectoryName + $extension = $file.extension + if (!$extension) { + $name = $file.name + ".txt" + } + else { + $name = $file.name + } + &7z.exe a -tgzip "$directory\$name.gz" "$directory\$filename" -sdel + } +} + +function Cleanup { + $ovsprocess = Get-Process ovs* -ErrorAction SilentlyContinue + $ovnprocess = Get-Process ovn* -ErrorAction SilentlyContinue + if ($ovsprocess) { + Stop-Process -name ovs* + } + if ($ovnprocess) { + Stop-Process -name ovn* + } + Remove-Item -Recurse -Force -ErrorAction SilentlyContinue -Path $commitDir +} + +function Start-MailJob ($user, $pass, $status) { + $uri = "http://10.20.1.3:8080/job/ovs-email-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$commitID&status=$status" + $pair = "${user}:${pass}" + $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) + $base64 = [System.Convert]::ToBase64String($bytes) + $basicAuthValue = "Basic $base64" + $headers = @{ Authorization = $basicAuthValue } + write-host "Starting the Mail Job for status $status" + Invoke-WebRequest -uri $uri -Headers $headers -UseBasicParsing +} + +function Set-MakeScript { +$makeScript = @" +#!/bin/bash +set -e +set -o pipefail +cd $msysCwd +echo `$INCLUDE +./boot.sh +./configure CC=./build-aux/cccl LD="C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/BIN/x86_amd64/link.exe" LIBS="-lws2_32 -liphlpapi -lwbemuuid -lole32 -loleaut32" --prefix="C:/ProgramData/openvswitch" \ +--localstatedir="C:/ProgramData/openvswitch" --sysconfdir="C:/ProgramData/openvswitch" \ +--with-pthread="$pthreadDir" --with-vstudiotarget="Debug" +make clean 2>&1 | tee makeoutput.log +make -j4 2>&1 | tee -a makeoutput.log +exit `$? +"@ + +$makeScriptPath = Join-Path $pwd "make.sh" +$makeScript.Replace("`r`n","`n") | Set-Content $makeScriptPath -Force +return $makeScriptPath +} + +function Set-UnitScript { +$unitScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make check TESTSUITEFLAGS="-j3" RECHECK=yes || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" || make check TESTSUITEFLAGS="--recheck" +exit `$? +"@ + +$unitScriptPath = Join-Path $pwd "unit.sh" +$unitScript.Replace("`r`n","`n") | Set-Content $unitScriptPath -Force +return $unitScriptPath +} + +function Set-MsiScript { +$msiScript = @" +#!/bin/bash +set -e +cd $msysCwd +echo `$INCLUDE +make windows_installer +exit `$? +"@ + +$msiScriptPath = Join-Path $pwd "msi.sh" +$msiScript.Replace("`r`n","`n") | Set-Content $msiScriptPath -Force +return $msiScriptPath +} + + +# Email job functions +function Send-Email ($from, $to, $status, $commitLink, $publiclogLink) { + $subject = "[ovs-build] ${status}: openvswitch/ovs (master - $commitID)" + $body = @" +
+Status: $status
+
+
+$commitMessage
+
+
+View the changeset:
+$commitLink
+
+View the full build log and details:
+$publiclogLink
+"@ + Send-MailMessage -from $from -to $to -subject $subject -body $body -BodyAsHtml -smtpServer $smtpServer +}