Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbergstrom committed Jan 2, 2020
2 parents 9de3d7c + 095b166 commit 82560e9
Show file tree
Hide file tree
Showing 28 changed files with 295 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*TestsResults.xml
*.nupkg
chocolatey.log
38 changes: 38 additions & 0 deletions Build.ps1
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.
6 changes: 4 additions & 2 deletions ChocolateyGet.psm1 → ChocolateyGet/ChocolateyGet.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ $script:firstTime = $true

# Utility variables
$script:FastReferenceRegex = "(?<name>[^#]*)#(?<version>[^\s]*)#(?<source>[^#]*)"
$script:ArgSplitRegex = '\B-(?:-|)'
$script:ArgFilterRegex = '\w*(?:param|arg)\w*'

Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -filename 'ChocolateyGet.Resource.psd1'

Expand All @@ -22,14 +24,14 @@ Microsoft.PowerShell.Utility\Import-LocalizedData LocalizedData -filename 'Choco
#region Methods

# Dot sourcing private script files
Get-ChildItem $ScriptPath/src/private -Recurse -Filter "*.ps1" -File | ForEach-Object {
Get-ChildItem $ScriptPath/src/private -Recurse -Filter "*.ps1" -File | ForEach-Object {
. $_.FullName
}

# Load and export methods

# Dot sourcing public function files
Get-ChildItem $ScriptPath/src/public -Recurse -Filter "*.ps1" -File | ForEach-Object {
Get-ChildItem $ScriptPath/src/public -Recurse -Filter "*.ps1" -File | ForEach-Object {
. $_.FullName

# Find all the functions defined no deeper than the first level deep and export it.
Expand Down
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.
131 changes: 131 additions & 0 deletions Jenkinsfile
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}" }
}
}
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[![Build status](https://ci.appveyor.com/api/projects/status/vxbk2jqy0r6y7cem/branch/master?svg=true)](https://ci.appveyor.com/project/jianyunt/chocolateyget/branch/master)

# ChocolateyGet
ChocolateyGet provider allows to download Chocolatey packages from any NuGet repository via OneGet

#### Jenkins Build Status - Production
[![Build Status](https://jenkins.cerner.com/communityworks/buildStatus/icon?job=CommunityWorks/ChocolateyGet/production)](https://jenkins.cerner.com/communityworks/blue/organizations/jenkins/CommunityWorks%2FChocolateyGet/activity)

#### Jenkins Build Status - Integration
[![Build Status](https://jenkins.cerner.com/communityworks/buildStatus/icon?job=CommunityWorks/ChocolateyGet/integration)](https://jenkins.cerner.com/communityworks/blue/organizations/jenkins/CommunityWorks%2FChocolateyGet/activity)

## Get the ChocolateyGet installed
```PowerShell
Expand Down
32 changes: 32 additions & 0 deletions Test.ps1
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
}
Loading

0 comments on commit 82560e9

Please sign in to comment.