Skip to content

Commit

Permalink
(GH-11) Remove ability to push on pack task
Browse files Browse the repository at this point in the history
- Rather, encourage user to use both a pack and push task
  • Loading branch information
gep13 committed Nov 21, 2018
1 parent abdad7f commit 30beb67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 98 deletions.
46 changes: 3 additions & 43 deletions Tasks/chocolatey/chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ try {
[string]$packWorkingDirectory = Get-VstsInput -Name 'packWorkingDirectory' -Require
[string]$packVersion = Get-VstsInput -Name 'packVersion'
[string]$packOutputDirectory = Get-VstsInput -Name 'packOutputDirectory'
[bool]$pushPackages = Get-VstsInput -Name 'pushPackages' -AsBool

if($packVersion) {
Write-Output "Adding --version to arguments"
Expand All @@ -189,37 +188,7 @@ try {
$chocolateyArguments.Add($packOutputDirectory) > $null
}

if($pushPackages) {
[string]$packSource = Get-VstsInput -Name 'packSource' -Default 'https://push.chocolatey.org/'
[string]$packApikey = Get-VstsInput -Name 'packApikey'
[bool]$packForce = Get-VstsInput -Name 'packForce' -AsBool -Default $false
[string]$packTimeout = Get-VstsInput -Name 'packTimeout'

if($packSource) {
Write-Output "Adding --source to arguments"
$chocolateyArguments.Add("--source") > $null
$chocolateyArguments.Add($packSource) > $null
}

if($packApikey) {
Write-Output "Adding --apikey to arguments"
$chocolateyArguments.Add("--apikey") > $null
$chocolateyArguments.Add($packApikey) > $null
}

if($packForce) {
Write-Output "Adding --force to arguments"
$chocolateyArguments.Add("--force") > $null
}

if($packTimeout) {
Write-Output "Adding -t to arguments"
$chocolateyArguments.Add("-t") > $null
$chocolateyArguments.Add($packTimeout) > $null
}

$commandName = "pack"
}
$commandName = "pack"
}
"push"
{
Expand Down Expand Up @@ -419,6 +388,7 @@ try {

Remove-Item "\*.nupkg"

# TODO: Need to add a globber pattern here for finding all nuspec's
if($packOperation -eq "single") {
[string]$packNuspecFileName = Get-VstsInput -Name 'packNuspecFileName' -Require
& $chocoExe $commandName $packNuspecFileName $($chocolateyArguments)
Expand All @@ -428,20 +398,10 @@ try {
& $chocoExe $commandName $nuspecFile $($chocolateyArguments)
}
}

if($pushPackages) {
if($outputDirectory){
Set-Location $outputDirectory
}

$nupkgFiles = Get-ChildItem "*.nupkg"
foreach($nupkgFile in $nupkgFiles) {
& $chocoExe push $nupkgFile $($chocolateyArguments)
}
}
} elseif($commandName -eq 'push') {
Set-Location $pushWorkingDirectory

# TODO: Need to add a globber patter here for finding all nupkg's
if($pushOperation -eq "single") {
[string]$pushNupkgFileName = Get-VstsInput -Name 'pushNupkgFileName' -Require
& $chocoExe $commandName $pushNupkgFileName $($chocolateyArguments)
Expand Down
61 changes: 6 additions & 55 deletions Tasks/chocolatey/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@
},
{
"name": "packWorkingDirectory",
"type": "string",
"type": "filePath",
"label": "Working Directory",
"defaultValue": "",
"defaultValue": "$(Build.Repository.LocalPath)",
"required": true,
"helpMarkDown": "The location of the nuspec file(s).",
"groupName": "packOptions"
Expand All @@ -387,62 +387,13 @@
},
{
"name": "packOutputDirectory",
"type": "string",
"type": "filePath",
"label": "Output Directory",
"defaultValue": "",
"defaultValue": "$(Build.ArtifactStagingDirectory)",
"required": false,
"helpMarkDown": "The location where the generated nupkg(s) should be placed.",
"groupName": "packOptions"
},
{
"name": "pushPackages",
"type": "boolean",
"label": "Push generated nupkg(s).",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Should the generated nupkg(s) also be pushed to the specified source?",
"groupName": "packOptions"
},
{
"name": "packSource",
"type": "string",
"label": "Source",
"defaultValue": "https://push.chocolatey.org/",
"required": false,
"helpMarkDown": "The source to push the generated nupkg(s) to.",
"visibleRule": "pushPackages=true",
"groupName": "packOptions"
},
{
"name": "packApikey",
"type": "string",
"label": "API Key",
"defaultValue": "",
"required": false,
"helpMarkDown": "The API Key that should be used to push the nupkg(s) to specified source.",
"visibleRule": "pushPackages=true",
"groupName": "packOptions"
},
{
"name": "packForce",
"type": "boolean",
"label": "Force.",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Force the operation to continue.",
"visibleRule": "pushPackages=true",
"groupName": "packOptions"
},
{
"name": "packTimeout",
"type": "string",
"label": "Timeout",
"defaultValue": "",
"required": false,
"helpMarkDown": "The time, in seconds, to allow a package push to occur before timing out.",
"visibleRule": "pushPackages=true",
"groupName": "packOptions"
},
{
"name": "pushOperation",
"type": "radio",
Expand All @@ -458,9 +409,9 @@
},
{
"name": "pushWorkingDirectory",
"type": "string",
"type": "filePath",
"label": "Working Directory",
"defaultValue": "",
"defaultValue": "$(Build.ArtifactStagingDirectory)",
"required": true,
"helpMarkDown": "The location of the nupkg file(s).",
"groupName": "pushOptions"
Expand Down

0 comments on commit 30beb67

Please sign in to comment.