Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 80 additions & 47 deletions CI/AZ_MainPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ resources:
type: github
name: tSQLt/tmp6
endpoint: GitHub-tSQLt-Robot
ref: (https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops) -- {{ $ArtifactBranchName }}


stages:
Expand All @@ -33,9 +32,43 @@ stages:
persistCredentials: true
path: tSQLtArtifacts

- task: PowerShell@2
name: list_remote_branch
inputs:
targetType: 'inline'
failOnStderr: false
script: |
$CheckIfGitOk = {param($isOk);if(-not $isOk){Write-Host "##vso[task.logissue type=error]GIT Failed!";throw "git failed!"}};

Set-Location "$(Pipeline.Workspace)\tSQLtArtifacts\";

Write-Host ("ArtifactBranchName: {0}" -f "$(ArtifactBranchName)");
try{

$remoteURL = git config remote.origin.url
$CheckIfGitOk.invoke($?);

$branch = (git ls-remote --heads $remoteURL $(ArtifactBranchName))
$CheckIfGitOk.invoke($?);

if( -not [string]::IsNullOrEmpty($branch) )
{
Write-Host "##vso[task.setvariable variable=BuiltAlready;isOutput=true]true";
Write-Host "Build Branch Found";
}
else
{
Write-Host "##vso[task.setvariable variable=BuiltAlready;isOutput=true]false";
Write-Host "Build Branch NOT Found";
};
}catch{
throw "git failed. See prior errors.";
}
git status

- job: CompileCLR
dependsOn: Check_If_Built_Already
condition: failed()
condition: and(succeeded(),eq(dependencies.Check_If_Built_Already.outputs['list_remote_branch.BuiltAlready'], 'false'))
timeoutInMinutes: 10
cancelTimeoutInMinutes: 2

Expand Down Expand Up @@ -125,12 +158,12 @@ stages:
targetType: 'inline'
failOnStderr: true
script: |
$BasePath = "$(Build.SourcesDirectory)\Build\output\";
$ArtifactPath = ($BasePath+"Artifact\");
New-Item -Path $ArtifactPath -ItemType directory -Force
$ArtifactFiles = (@("Version.txt","tSQLt.zip","tSQLt.tests.zip")|%{$BasePath+$_});
$ArtifactFiles|Copy-Item -Verbose -Destination $ArtifactPath;
Set-Content -Path ($ArtifactPath+"CommitId.txt") -Value "$(Build.SourceVersion)"
$basePath = "$(Build.SourcesDirectory)\Build\output\";
$artifactPath = ($basePath+"Artifact\");
New-Item -Path $artifactPath -ItemType directory -Force
$ArtifactFiles = (@("Version.txt","tSQLt.zip","tSQLt.tests.zip")|%{$basePath+$_});
$ArtifactFiles|Copy-Item -Verbose -Destination $artifactPath;
Set-Content -Path ($artifactPath+"CommitId.txt") -Value "$(Build.SourceVersion)"

- task: PublishPipelineArtifact@1
inputs:
Expand All @@ -148,6 +181,7 @@ stages:
- checkout: tSQLtArtifacts
clean: true
lfs: false
fetchDepth: 1
persistCredentials: true
path: tSQLtArtifacts

Expand All @@ -158,6 +192,11 @@ stages:
artifactName: 'tSQLtAndTests'
targetPath: '$(Pipeline.Workspace)\tmp'

- task: AzureKeyVault@1
inputs:
azureSubscription: 'tSQLt CI Subscription(58c04a99-5b92-410c-9e41-10262f68ca80)'
KeyVaultName: 'tSQLtSigningKey'

- task: PowerShell@2
name: StoreInArtifactRepo
env:
Expand All @@ -170,7 +209,6 @@ stages:
script: |
$CheckIfGitOk = {param($isOk);if(-not $isOk){Write-Host "##vso[task.logissue type=error]GIT Failed!";throw "GIT Failed!"}};

Get-Location;
Set-Location "$(Pipeline.Workspace)\tSQLtArtifacts\";
Write-Host ("ArtifactBranchName: {0}" -f "$(ArtifactBranchName)");
try{
Expand All @@ -179,6 +217,12 @@ stages:
git status
git remote show origin

Write-Host "✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ";
Write-Host "";
git branch --remotes
Write-Host "";
Write-Host "✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ✨ ";

git switch -c "$(ArtifactBranchName)"
$CheckIfGitOk.invoke($?);

Expand Down Expand Up @@ -217,7 +261,6 @@ stages:
strategy:
matrix: {
'2008R2':{'SQLVersionEdition':'2008R2Std'},
'2008R2E':{'SQLVersionEdition':'2008R2Ent'},
'2012':{'SQLVersionEdition':'2012Ent'},
'2014':{'SQLVersionEdition':'2014'},
'2016':{'SQLVersionEdition':'2016'},
Expand All @@ -242,6 +285,7 @@ stages:
- checkout: tSQLtArtifacts
clean: true
lfs: false
fetchDepth: 1
persistCredentials: true
path: tSQLtArtifacts

Expand All @@ -250,27 +294,22 @@ stages:
inputs:
targetType: 'inline'
script: |
$ArtifactTargetPath= '$(Pipeline.Workspace)/tSQLt/Build_Artifact'
$CheckIfGitOk = {param($isOk);if(-not $isOk){Write-Host "##vso[task.logissue type=error]GIT Failed!";throw "GIT Failed!"}};

Set-Location "$(Pipeline.Workspace)\tSQLtArtifacts\";

# Write-Host ("ArtifactBranchName: {0}" -f "$(ArtifactBranchName)");
# try{
# git status
# git remote show origin

# git fetch
# git checkout "$(ArtifactBranchName)"
# $CheckIfGitOk.invoke($?);
Set-Location "$(Pipeline.Workspace)/tSQLtArtifacts";
$ArtifactTargetPath= '$(Pipeline.Workspace)/tSQLt/Build_Artifact'
Write-Host ("ArtifactBranchName: {0}" -f "$(ArtifactBranchName)");

# git status
# }catch{
# throw "Git Failed. See prior errors.";
# }
try{
git fetch origin $(ArtifactBranchName):$(ArtifactBranchName)
$CheckIfGitOk.invoke($?);
git checkout $(ArtifactBranchName)
$CheckIfGitOk.invoke($?);
}catch{
throw "git failed. See prior errors.";
}

New-Item -Path $ArtifactTargetPath -ItemType directory -Force

Copy-Item -Path "*" -Verbose -Destination $ArtifactTargetPath

- task: AzurePowerShell@4
Expand All @@ -288,12 +327,7 @@ stages:
azurePowerShellVersion: 'LatestVersion'
ScriptType: 'InlineScript'
Inline: |
Write-Host '$(Build.Repository.LocalPath)';
(Get-ChildItem);
Set-Location $(Build.Repository.LocalPath)/..
(Get-ChildItem);
Set-Location $(Build.Repository.LocalPath)/../tSQLt
(Get-ChildItem);
Set-Location $(Pipeline.Workspace)/tSQLt
.("CI/CommonFunctionsAndMethods.ps1")

$SqlPort = Get-Random -minimum $env:SQLPORTMINIMUM -maximum $env:SQLPORTMAXIMUM
Expand Down Expand Up @@ -363,11 +397,11 @@ stages:
- task: Ant@1
name: Run_tSQLt_validatebuild_xml
inputs:
buildFile: '../tSQLt/Build/tSQLt.validatebuild.xml'
buildFile: '$(Pipeline.Workspace)/tSQLt/Build/tSQLt.validatebuild.xml'
options: '-Ddb.version="$(SQLVersion)" -Ddb.server="$(FQDNAndPort)" -Ddb.name=tSQLt_dev -Ddb.login="-U $(tSQLt-UserForCIEnvironment-UserName) -P $(tSQLt-UserForCIEnvironment-Password)" -Dsqlcmd.path="$(SQLCMDPath)"'
targets: 'all'
publishJUnitResults: true
testResultsFiles: '../**/?(Example)TestResults*.xml'
testResultsFiles: '$(Pipeline.Workspace)/tSQLt/**/?(Example)TestResults*.xml'
testRunTitle: '$(SQLVersionEdition)'
javaHomeOption: 'JDKVersion'

Expand All @@ -378,26 +412,25 @@ stages:
failOnStderr: true
script: |
"---------------------------------------------------"
$BasePath = "$(Build.SourcesDirectory)\..";
$BasePath;
$basePath = "$(Pipeline.Workspace)";
$basePath;
"==================================================="
$ArtifactPath = ($BasePath+"\tSQLt\Build\output\TestResults\");
$ArtifactPath;
$artifactPath = "$basePath\tSQLt\Build\output\TestResults\";
$artifactPath;
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
New-Item -Path $ArtifactPath -ItemType directory -Force
(Get-ChildItem $BasePath -recurse);
New-Item -Path $artifactPath -ItemType directory -Force
"== == == == == == == == == == == == == == == == == "
(Get-ChildItem $BasePath -recurse)|Out-File -FilePath $ArtifactPath+"dir.txt"
(Get-ChildItem $BasePath -recurse -include "*TestResults*.xml").FullName;
(Get-ChildItem $basePath -recurse)|Out-File -FilePath $artifactPath+"dir.txt"
(Get-ChildItem $basePath -recurse -include "*TestResults*.xml").FullName;
"==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-"
(Get-ChildItem $BasePath -recurse -include "*TestResults*.xml").FullName|Copy-Item -Destination $ArtifactPath -recurse -PassThru
Set-Content -Path ($ArtifactPath+"CommitId.txt") -Value "$(Build.SourceVersion)"
(Get-ChildItem $basePath -recurse -include "*TestResults*.xml").FullName|Copy-Item -Destination $artifactPath -recurse -PassThru
Set-Content -Path ($artifactPath+"CommitId.txt") -Value "$(Build.SourceVersion)"
"=== === === === === === === === === === === === ==="

- task: PublishPipelineArtifact@1
name: PublishTestResultArtifact
inputs:
targetPath: '$(Build.SourcesDirectory)/../tSQLt/Build/output/TestResults'
targetPath: '$(Pipeline.Workspace)/tSQLt/Build/output/TestResults'
artifact: 'TestResults_$(SQLVersionEdition)'
publishLocation: 'pipeline'

Expand All @@ -409,7 +442,7 @@ stages:
inputs:
targetType: 'inline'
script: |
$CheckIfGitOk = {param($isOk);if(-not $isOk){Write-Host "##vso[task.logissue type=error]GIT Failed!";throw "GIT Failed!"}};
$CheckIfGitOk = {param($isOk);if(-not $isOk){Write-Host "##vso[task.logissue type=error]git failed!";throw "git failed!"}};

$TagName = "$(SQLVersionEdition)_$(Build.BuildId)"

Expand All @@ -431,7 +464,7 @@ stages:

git status
}catch{
throw "Git Failed. See prior errors.";
throw "git failed. See prior errors.";
}

##--##--##--##--##--##--##--##--##--##---##--##--##--##--##--##--##--##--##--##
Expand Down