Skip to content

Commit 6370073

Browse files
Change dry-run to push to NuGet Test/QA environment (#4032)
* Task 43000: Change dry-run to push to NuGet INT environment - Updated OneBranch pipelines to use the NuGet Test/QA service instead of the dry run concept. * Task 43000: Change dry-run to push to NuGet INT environment - Fixed variable expansion issues. * Task 43000: Change dry-run to push to NuGet INT environment - Added doagnostics to release jobs to see what packages will be pushed. * Task 43000: Change dry-run to push to NuGet INT environment - Moved NuGet service connection names into release-stages just like the other release environment values. --------- Co-authored-by: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com>
1 parent 3618815 commit 6370073

5 files changed

Lines changed: 92 additions & 79 deletions

File tree

eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,16 @@ parameters:
5252
type: string
5353
default: ''
5454

55-
# When true, lists the package that would be published without actually pushing.
56-
- name: isDryRun
57-
type: boolean
58-
default: false
55+
# Optional suffix appended to display names (e.g. ' (NuGet Test)').
56+
- name: displaySuffix
57+
type: string
58+
default: ''
59+
5960

6061
# Read more: https://eng.ms/docs/products/onebranch/release/yamlreleasepipelines/pipelinebasics#what-is-a-onebranch-release-yaml-pipeline
6162
jobs:
6263
- job: publish_${{ replace(parameters.packageName, '.', '_') }}
63-
displayName: Publish ${{ parameters.packageName }}
64+
displayName: Publish ${{ parameters.packageName }}${{ parameters.displaySuffix }}
6465

6566
variables:
6667
- name: ob_outputDirectory
@@ -89,20 +90,26 @@ jobs:
8990

9091
# Artifacts are downloaded via templateContext.inputs per OneBranch requirements.
9192

92-
- ${{ if eq(parameters.isDryRun, true) }}:
93-
- pwsh: |
94-
Write-Host "##[section]DRY RUN — The following packages would be published:"
95-
96-
Get-ChildItem -Path "$(packageToPush)" -ErrorAction SilentlyContinue
97-
98-
Write-Host "##[warning]DRY RUN — No packages were pushed."
99-
displayName: Dry Run — List ${{ parameters.packageName }} packages
100-
101-
- ${{ else }}:
102-
- task: NuGetCommand@2
103-
displayName: Push ${{ parameters.packageName }} to NuGet
104-
inputs:
105-
command: push
106-
packagesToPush: $(packageToPush)
107-
nuGetFeedType: external
108-
publishFeedCredentials: ${{ parameters.nugetServiceConnection }}
93+
# Emit details about what is being published.
94+
- pwsh: |
95+
Write-Host "artifactPath: $(artifactPath)"
96+
Write-Host "packageToPush: $(packageToPush)"
97+
Get-ChildItem -Path "$(artifactPath)" -Recurse | Format-Table -AutoSize
98+
if (Test-Path "$(packageToPush)")
99+
{
100+
Write-Host "Package found: $(packageToPush)"
101+
}
102+
else
103+
{
104+
Write-Error "Package not found: $(packageToPush)"
105+
}
106+
displayName: Show Package(s) to Push
107+
108+
# Push the package(s) to NuGet.
109+
- task: NuGetCommand@2
110+
displayName: Push ${{ parameters.packageName }} to NuGet${{ parameters.displaySuffix }}
111+
inputs:
112+
command: push
113+
packagesToPush: $(packageToPush)
114+
nuGetFeedType: external
115+
publishFeedCredentials: ${{ parameters.nugetServiceConnection }}

eng/pipelines/onebranch/sqlclient-non-official.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,11 @@ extends:
191191
- template: /eng/pipelines/onebranch/stages/release-stages.yml@self
192192
parameters:
193193
debug: ${{ parameters.debug }}
194-
# Non-official pipelines must always be a dry run.
195-
isDryRun: true
196-
# This is _not_ official pipeline.
194+
# Non-official pipelines always push to the NuGet Test feed.
195+
releaseToProduction: false
196+
# This is _not_ an official pipeline.
197197
isOfficial: false
198198
stageNameSuffix: test
199-
stageDisplayName: Release Test (Dry Run)
200199
releaseSqlServerServer: ${{ parameters.releaseSqlServerServer }}
201200
releaseLogging: ${{ parameters.releaseLogging }}
202201
releaseAbstractions: ${{ parameters.releaseAbstractions }}

eng/pipelines/onebranch/sqlclient-official.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ parameters:
3333
type: boolean
3434
default: false
3535

36+
# Push packages to NuGet Production (otherwise pushes to NuGet Test).
37+
- name: releaseToProduction
38+
displayName: Release to NuGet Production
39+
type: boolean
40+
default: false
41+
3642
# True if this is a preview build.
3743
- name: isPreview
3844
displayName: Is this a preview build?
@@ -45,12 +51,6 @@ parameters:
4551
type: boolean
4652
default: false
4753

48-
# Release Dry Run (do not push to NuGet)
49-
- name: releaseDryRun
50-
displayName: Release Dry Run (do not push to NuGet)
51-
type: boolean
52-
default: true
53-
5454
# Build parameters — select which packages to build.
5555

5656
# Build the Microsoft.SqlServer.Server package.
@@ -216,14 +216,10 @@ extends:
216216
- template: /eng/pipelines/onebranch/stages/release-stages.yml@self
217217
parameters:
218218
debug: ${{ parameters.debug }}
219-
isDryRun: ${{ parameters.releaseDryRun }}
219+
releaseToProduction: ${{ parameters.releaseToProduction }}
220220
# This is an official pipeline.
221221
isOfficial: true
222222
stageNameSuffix: production
223-
${{ if eq(parameters.releaseDryRun, true) }}:
224-
stageDisplayName: Release Production (Dry Run)
225-
${{ else }}:
226-
stageDisplayName: Release Production
227223
releaseSqlServerServer: ${{ parameters.releaseSqlServerServer }}
228224
releaseLogging: ${{ parameters.releaseLogging }}
229225
releaseAbstractions: ${{ parameters.releaseAbstractions }}

eng/pipelines/onebranch/stages/release-stages.yml

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
# stages:
1111
# - template: /eng/pipelines/onebranch/stages/release-stages.yml@self
1212
# parameters:
13-
# isOfficial: true # or false
14-
# isDryRun: true # or false
13+
# isOfficial: true # or false
14+
# releaseToProduction: false # or true
1515
# ...
1616
#
1717
# The isOfficial flag controls release-stage behaviour:
18-
# - Official → Production environment, approval gate, dryRun parameter
19-
# - Non-Official → Test environment, dry-run always enforced
18+
# - Official → Production environment, approval gate.
19+
# - Non-Official → Test environment.
20+
#
21+
# The releaseToProduction flag controls where packages are pushed:
22+
# - true → NuGet Production feed (via NuGetServiceConnectionProd).
23+
# - false → NuGet Test feed (via NuGetServiceConnectionTest).
2024
#
2125
# This template depends on stages defined by the build-stages.yml template.
2226
#
@@ -36,33 +40,26 @@ parameters:
3640
- name: debug
3741
type: boolean
3842

39-
# True for this to be a dry-run of the release portion of the pipeline. A dry run will ask
40-
# for approvals and list the packages that would be released.
43+
# Controls where packages are pushed during the release stage.
4144
#
42-
# When false, a release will actually push packages to NuGet.
45+
# When true, packages are pushed to the NuGet Production feed.
46+
# When false (default), packages are pushed to the NuGet Test feed.
4347
#
44-
- name: isDryRun
48+
- name: releaseToProduction
4549
type: boolean
46-
default: true
50+
default: false
4751

4852
# True for a OneBranch Official pipeline, false for a Non-Official pipeline.
4953
- name: isOfficial
5054
type: boolean
5155

52-
# We must take these names as parameters because they are used in the stage name and display name,
53-
# which cannot be computed within the template.
54-
55-
# The stage name suffix.
56+
# The stage name suffix, used in the stage ID (e.g. release_production) and display name.
5657
- name: stageNameSuffix
5758
type: string
5859
values:
5960
- production
6061
- test
6162

62-
# The stage display name.
63-
- name: stageDisplayName
64-
type: string
65-
6663
# ── Release parameters ─────────────────────────────────────────────────
6764

6865
- name: releaseSqlServerServer
@@ -90,13 +87,19 @@ stages:
9087
# Compile-time conditional: stage is removed entirely when no release
9188
# parameters are selected, avoiding OneBranch validation errors.
9289
#
93-
# Official pipeline → Production environment, approval gate,
94-
# dryRun controlled by releaseDryRun parameter.
95-
# Non-official pipeline → Test/DryRun environment, dryRun always true.
90+
# Official pipeline → Production environment, approval gate.
91+
# Non-official pipeline → Test environment.
92+
#
93+
# releaseToProduction controls NuGet target:
94+
# true → NuGet Production feed.
95+
# false → NuGet Test feed.
9696
# ====================================================================
9797
- ${{ if or(parameters.releaseSqlServerServer, parameters.releaseLogging, parameters.releaseAbstractions, parameters.releaseSqlClient, parameters.releaseAzure, parameters.releaseAKVProvider) }}:
9898
- stage: release_${{ parameters.stageNameSuffix }}
99-
displayName: ${{ parameters.stageDisplayName }}
99+
${{ if eq(parameters.releaseToProduction, true) }}:
100+
displayName: Release to NuGet Production
101+
${{ else }}:
102+
displayName: Release to NuGet Test
100103
dependsOn:
101104
- ${{ if or(parameters.releaseSqlServerServer, parameters.releaseLogging) }}:
102105
- build_independent
@@ -128,63 +131,80 @@ stages:
128131
- name: ob_deploymentjob_environment
129132
value: ${{ variables.onebranchDeploymentEnvironment }}
130133

134+
# NuGet service connection names used by the release stage to push packages.
135+
# These must match the ADO service connections configured with NuGet.org
136+
# credentials (API key or federated auth).
137+
- name: nugetServiceConnection
138+
${{ if eq(parameters.releaseToProduction, true) }}:
139+
# https://sqlclientdrivers.visualstudio.com/ADO.Net/_settings/adminservices?resourceId=ee834e3a-87ad-4e9d-aa19-23711cfe4500
140+
value: ADO Nuget Org Connection
141+
${{ else }}:
142+
# https://sqlclientdrivers.visualstudio.com/ADO.Net/_settings/adminservices?resourceId=4dd2f6b9-2696-4324-bee5-0b4f9c273098
143+
value: ADO Nuget Org Test Connection
144+
145+
- name: nugetTargetSuffix
146+
${{ if eq(parameters.releaseToProduction, true) }}:
147+
value: ' (NuGet Production)'
148+
${{ else }}:
149+
value: ' (NuGet Test)'
150+
131151
jobs:
132152
- ${{ if eq(parameters.releaseSqlServerServer, true) }}:
133153
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
134154
parameters:
135155
packageName: Microsoft.SqlServer.Server
136156
artifactName: drop_build_independent_build_package_SqlServer
137157
packagePath: Microsoft.SqlServer.Server.$(effectiveSqlServerVersion).nupkg
138-
nugetServiceConnection: $(NuGetServiceConnection)
158+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
139159
isProduction: ${{ parameters.isOfficial }}
140-
isDryRun: ${{ parameters.isDryRun }}
160+
displaySuffix: ${{ variables.nugetTargetSuffix }}
141161

142162
- ${{ if eq(parameters.releaseLogging, true) }}:
143163
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
144164
parameters:
145165
packageName: Microsoft.Data.SqlClient.Internal.Logging
146166
artifactName: drop_build_independent_build_package_Logging
147167
packagePath: Microsoft.Data.SqlClient.Internal.Logging.$(effectiveLoggingVersion).nupkg
148-
nugetServiceConnection: $(NuGetServiceConnection)
168+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
149169
isProduction: ${{ parameters.isOfficial }}
150-
isDryRun: ${{ parameters.isDryRun }}
170+
displaySuffix: ${{ variables.nugetTargetSuffix }}
151171

152172
- ${{ if eq(parameters.releaseAbstractions, true) }}:
153173
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
154174
parameters:
155175
packageName: Microsoft.Data.SqlClient.Extensions.Abstractions
156176
artifactName: drop_build_abstractions_build_package_Abstractions
157177
packagePath: Microsoft.Data.SqlClient.Extensions.Abstractions.$(effectiveAbstractionsVersion).nupkg
158-
nugetServiceConnection: $(NuGetServiceConnection)
178+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
159179
isProduction: ${{ parameters.isOfficial }}
160-
isDryRun: ${{ parameters.isDryRun }}
180+
displaySuffix: ${{ variables.nugetTargetSuffix }}
161181

162182
- ${{ if eq(parameters.releaseSqlClient, true) }}:
163183
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
164184
parameters:
165185
packageName: Microsoft.Data.SqlClient
166186
artifactName: drop_build_dependent_build_package_SqlClient
167187
packagePath: Microsoft.Data.SqlClient.$(effectiveSqlClientVersion).nupkg
168-
nugetServiceConnection: $(NuGetServiceConnection)
188+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
169189
isProduction: ${{ parameters.isOfficial }}
170-
isDryRun: ${{ parameters.isDryRun }}
190+
displaySuffix: ${{ variables.nugetTargetSuffix }}
171191

172192
- ${{ if eq(parameters.releaseAzure, true) }}:
173193
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
174194
parameters:
175195
packageName: Microsoft.Data.SqlClient.Extensions.Azure
176196
artifactName: drop_build_dependent_build_package_Azure
177197
packagePath: Microsoft.Data.SqlClient.Extensions.Azure.$(effectiveAzureVersion).nupkg
178-
nugetServiceConnection: $(NuGetServiceConnection)
198+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
179199
isProduction: ${{ parameters.isOfficial }}
180-
isDryRun: ${{ parameters.isDryRun }}
200+
displaySuffix: ${{ variables.nugetTargetSuffix }}
181201

182202
- ${{ if eq(parameters.releaseAKVProvider, true) }}:
183203
- template: /eng/pipelines/onebranch/jobs/publish-nuget-package-job.yml@self
184204
parameters:
185205
packageName: Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider
186206
artifactName: drop_build_addons_build_package_AkvProvider
187207
packagePath: Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.$(effectiveAkvProviderVersion).nupkg
188-
nugetServiceConnection: $(NuGetServiceConnection)
208+
nugetServiceConnection: ${{ variables.nugetServiceConnection }}
189209
isProduction: ${{ parameters.isOfficial }}
190-
isDryRun: ${{ parameters.isDryRun }}
210+
displaySuffix: ${{ variables.nugetTargetSuffix }}

eng/pipelines/onebranch/variables/common-variables.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,3 @@ variables:
180180
value: $(SymbolsPublishServer)
181181
- name: SymbolTokenUri
182182
value: $(SymbolsPublishTokenUri)
183-
184-
# ----------------------------------------------------------------------------
185-
# Release Variables
186-
#
187-
# NuGet service connection used by the release stage to push packages.
188-
# This should match the name of an ADO service connection configured with
189-
# NuGet.org credentials (API key or federated auth).
190-
- name: NuGetServiceConnection
191-
value: ADO Nuget Org Connection

0 commit comments

Comments
 (0)