Skip to content

Commit b3a40c9

Browse files
committed
Work CI-CD
- Add task to count artifacts in order to skip following tasks if there are none. ***NO_CI***
1 parent cc2f59f commit b3a40c9

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

azure-pipelines.yml

+27-3
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,26 @@ steps:
9090
TargetFolder: '$(Build.ArtifactStagingDirectory)'
9191
flattenFolders: true
9292

93+
# find if there are NuGet artifacts
94+
- task: PowerShell@2
95+
displayName: Count artifacts
96+
name: Count_Artifacts
97+
inputs:
98+
workingDirectory: '$(Build.ArtifactStagingDirectory)'
99+
targetType: inline
100+
script: |
101+
$count = (Get-ChildItem -Path '.' -Filter '*.nupkg' -Recurse).Count
102+
Write-Host $count + ' NuGet packages found'
103+
104+
# set variable to forward
105+
echo "##vso[task.setvariable variable=NUGET_COUNT;isOutput=true]$count"
106+
93107
- task: DotNetCoreCLI@2
94108
displayName: Install SignTool tool
95109
condition: >-
96110
and(
97111
succeeded(),
112+
gt(variables.NUGET_COUNT, 0),
98113
eq(variables['System.PullRequest.PullRequestId'], '')
99114
)
100115
inputs:
@@ -115,9 +130,14 @@ steps:
115130
--descriptionUrl "https://github.com/$env:Build_Repository_Name"
116131
displayName: Sign packages
117132
continueOnError: true
118-
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
133+
condition: >-
134+
and(
135+
succeeded(),
136+
gt(variables.NUGET_COUNT, 0),
137+
eq(variables['System.PullRequest.PullRequestId'], '')
138+
)
119139
120-
# publish artifacts (only possible if this is not a PR originated on a fork)
140+
# publish artifacts
121141
- task: PublishBuildArtifacts@1
122142
condition: succeeded()
123143
displayName: Publish deployables artifacts
@@ -136,6 +156,7 @@ steps:
136156
condition: >-
137157
and(
138158
succeeded(),
159+
gt(variables.NUGET_COUNT, 0),
139160
eq(variables['System.PullRequest.PullRequestId'], '')
140161
)
141162
continueOnError: false
@@ -147,6 +168,7 @@ steps:
147168
condition: >-
148169
and(
149170
succeeded(),
171+
gt(variables.NUGET_COUNT, 0),
150172
eq(variables['System.PullRequest.PullRequestId'], '')
151173
)
152174
continueOnError: false
@@ -157,6 +179,7 @@ steps:
157179
condition: >-
158180
and(
159181
succeeded(),
182+
gt(variables.NUGET_COUNT, 0),
160183
eq(variables['System.PullRequest.PullRequestId'], '')
161184
)
162185
inputs:
@@ -166,12 +189,13 @@ steps:
166189
workingDirectory: 'nanoFramework.IoT.Device'
167190

168191
- task: PowerShell@2
192+
displayName: Push READMEs to GitHub
169193
condition: >-
170194
and(
171195
succeeded(),
196+
gt(variables.NUGET_COUNT, 0),
172197
eq(variables['System.PullRequest.PullRequestId'], '')
173198
)
174-
displayName: Push READMEs to GitHub
175199
continueOnError: true
176200
inputs:
177201
workingDirectory: 'nanoFramework.IoT.Device'

0 commit comments

Comments
 (0)