-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
295 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*TestsResults.xml | ||
*.nupkg | ||
chocolatey.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[CmdletBinding()] | ||
param( | ||
[String]$PackageName = (Split-Path $PSScriptRoot -Leaf), | ||
[String]$RepoName = 'TempLocalPSRepo', | ||
[String]$RepoLocation = $PSScriptRoot, | ||
[String]$NuGetApiKey | ||
) | ||
|
||
Remove-Module -Name $PackageName -Force -ErrorAction SilentlyContinue | ||
|
||
if ((Get-PSRepository -Name $RepoName -ErrorAction SilentlyContinue) -ne $null) { | ||
Unregister-PSRepository -Name $RepoName | ||
} | ||
Register-PSRepository -Name $RepoName -SourceLocation $RepoLocation -PublishLocation $RepoLocation | ||
|
||
if (((Find-Package -Name $PackageName -Source $RepoName -ErrorAction SilentlyContinue) -ne $null) -and (!$NuGetApiKey)) { | ||
Remove-Item (Join-Path -Path $RepoLocation -ChildPath "$PackageName*.nupkg") | ||
} | ||
|
||
$publishParams = @{ | ||
Repository = $RepoName | ||
Force = $True | ||
Path = "$PSScriptRoot\$PackageName" | ||
} | ||
|
||
Copy-Item -Recurse ".\$PackageName" "$Env:ProgramFiles\WindowsPowerShell\Modules\" -Force -Verbose | ||
|
||
if ($NuGetApiKey) { | ||
$publishParams.Add('nuGetApiKey',$NuGetApiKey) | ||
} | ||
|
||
try { | ||
Publish-Module @publishParams | ||
} | ||
finally { | ||
Remove-Item -Recurse "$Env:ProgramFiles\WindowsPowerShell\Modules\$PackageName" -Force -Verbose | ||
Unregister-PSRepository -Name $RepoName | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Obtain an Artifactory server instance, defined in Jenkins --> Manage: | ||
def server = Artifactory.server 'net.cernerrepos' | ||
|
||
pipeline { | ||
agent { | ||
label 'windows_corporate' | ||
} | ||
triggers { | ||
githubPush() | ||
} | ||
options { | ||
skipStagesAfterUnstable() | ||
} | ||
environment { | ||
PACKAGE_NAME = 'ChocolateyGet' | ||
TEAMS_URL = 'https://outlook.office.com/webhook/c70adb63-caaf-4054-acd9-ffc39745b11c@fbc493a8-0d24-4454-a815-f4ca58e8c09d/IncomingWebhook/2e708b5e781f48f99cd4e5223d6b6ddd/db882129-a743-4298-9b1d-53922a4a3d7b' | ||
ARTIFACTORY_INTEGRATION_REPO = 'nuget-integration-local' | ||
ARTIFACTORY_PRODUCTION_REPO = 'nuget-production-local' | ||
} | ||
stages { | ||
stage('Build') { | ||
steps { | ||
powershell "\$ErrorActionPreference = 'Stop'; ./Build.ps1 -PackageName ${env.PACKAGE_NAME}; exit \$lastexitcode" | ||
} | ||
} | ||
stage('Test') { | ||
steps { | ||
script { | ||
try { | ||
powershell "\$ErrorActionPreference = 'Stop'; ./Test.ps1 -PreBuilt -PackageName ${env.PACKAGE_NAME}; exit \$lastexitcode" | ||
} | ||
finally { | ||
nunit testResultsPattern: "*_TestsResults.xml" | ||
archiveArtifacts 'chocolatey.log' | ||
} | ||
} | ||
} | ||
} | ||
stage('Deploy to Integration') { | ||
// Has passed the PR check, and commited - pushing to integration store | ||
when { | ||
allOf { | ||
not{ | ||
changeRequest () | ||
} | ||
} | ||
branch 'integration' | ||
} | ||
steps { | ||
script { | ||
// Create the upload specs: | ||
def uploadSpec = """{ | ||
"files": [ | ||
{ | ||
"pattern" : "${env.PACKAGE_NAME}*.nupkg", | ||
"target" : "${env.ARTIFACTORY_INTEGRATION_REPO}/" | ||
} | ||
] | ||
}""" | ||
|
||
// Upload files to Artifactory: | ||
buildInfo = server.upload spec: uploadSpec | ||
|
||
// Publish the merged build-info to Artifactory | ||
server.publishBuildInfo buildInfo | ||
} | ||
} | ||
} | ||
stage('Deploy to Production') { | ||
// Has passed the PR check, and commited - pushing to integration store | ||
when { | ||
allOf { | ||
not{ | ||
changeRequest () | ||
} | ||
} | ||
branch 'production' | ||
} | ||
steps { | ||
script { | ||
// Create the upload specs: | ||
def uploadSpec = """{ | ||
"files": [ | ||
{ | ||
"pattern" : "${env.PACKAGE_NAME}*.nupkg", | ||
"target" : "${env.ARTIFACTORY_INTEGRATION_REPO}/" | ||
} | ||
] | ||
}""" | ||
|
||
// Upload files to Artifactory: | ||
buildInfo = server.upload spec: uploadSpec | ||
|
||
// Publish the merged build-info to Artifactory | ||
server.publishBuildInfo buildInfo | ||
|
||
// Create the promotion specs: | ||
def promotionConfig = [ | ||
// Mandatory parameters | ||
'buildName' : buildInfo.name, | ||
'buildNumber' : buildInfo.number, | ||
'targetRepo' : env.ARTIFACTORY_PRODUCTION_REPO, | ||
|
||
// Optional parameters | ||
'sourceRepo' : env.ARTIFACTORY_INTEGRATION_REPO, | ||
'status' : 'Released', | ||
'includeDependencies': true, | ||
'copy' : true, | ||
] | ||
|
||
// Promote build to Production: | ||
server.promote promotionConfig | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
powershell "Remove-Item ${env.PACKAGE_NAME}*.nupkg -ErrorAction SilentlyContinue" | ||
} | ||
success { | ||
script { teamsNotifySuccess "${env.TEAMS_URL}" } | ||
} | ||
unstable { | ||
script { teamsNotifyUnstable "${env.TEAMS_URL}" } | ||
} | ||
failure { | ||
script { teamsNotifyFailure "${env.TEAMS_URL}" } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[CmdletBinding()] | ||
param( | ||
[String]$RepoName = 'TempLocalPSRepo', | ||
[String]$RepoLocation = $PSScriptRoot, | ||
[String]$PackageName = (Split-Path $PSScriptRoot -Leaf), | ||
[Switch]$Prebuilt, | ||
[String]$BuildScript = './build.ps1' | ||
) | ||
|
||
if (!$Prebuilt) { | ||
. $BuildScript -PackageName $PackageName -RepoName $RepoName -RepoLocation $RepoLocation | ||
} | ||
|
||
if ((Get-PSRepository -Name $RepoName -ErrorAction SilentlyContinue) -ne $null) { | ||
Unregister-PSRepository -Name $RepoName | ||
} | ||
Register-PSRepository -Name $RepoName -SourceLocation $RepoLocation -PublishLocation $RepoLocation | ||
|
||
$chocoLogPath = Get-Command -Name 'choco' | Split-Path | Split-Path | Join-Path -ChildPath 'logs\chocolatey.log' | ||
Rename-Item -Path $chocoLogPath -NewName "chocolatey.$(Get-Date -Format 'yyyyMMddHHmmss').log" | ||
|
||
try { | ||
Uninstall-Package -Name $PackageName -Force -ErrorAction SilentlyContinue | ||
Install-Package -Name $PackageName -Source $RepoName -Force | ||
|
||
Invoke-Pester "./Test/$PackageName.tests.ps1" -OutputFile worker_TestsResults.xml -OutputFormat NUnitXML | ||
} | ||
finally { | ||
Copy-Item -Path $chocoLogPath -Destination '.' -Force | ||
Uninstall-Package -Name $PackageName -Force | ||
Unregister-PSRepository -Name $RepoName | ||
} |
Oops, something went wrong.