Skip to content

Commit 973304c

Browse files
committed
adjusted the repo structure to include azure_pipeline task
1 parent 1de7c3a commit 973304c

38 files changed

+885
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and Release for Azure Pipeline
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '14'
18+
19+
- name: Install dependencies and build
20+
run: |
21+
cd ./src
22+
npm install
23+
cd ..
24+
25+
- name: Install tfx-cli
26+
run: |
27+
npm install -g tfx-cli
28+
29+
- name: Create extension
30+
run: |
31+
tfx extension create --manifest-globs vss-extension.json
32+
33+
- name: Upload VSIX file
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: VSIX file
37+
path: ./*.vsix

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
azure_pipeline/src/dist/
2+
azure_pipeline/src/node_modules/
3+
azure_pipeline/src/package-lock.json

azure_pipeline/development.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# Azure Pipeline task: NGINX for Azure Configuration Push (Development Guide)
2+
3+
4+
For the developing and publishing of the pipeline task, there are two ways to build and update the Azure DevOps pipeline tasks onto the market place if there are any new fixes or patches.
5+
6+
## Plan A. Manual Update
7+
8+
### Step 1. Get vss-extension.json ready for packaging
9+
10+
Vss-extension.json defines all information about your extension that will be displayed in the marketplace.
11+
12+
Please not that the name and id of this file is not finalized.
13+
14+
```
15+
16+
// vss-extension.json
17+
18+
{
19+
"manifestVersion": 1,
20+
"id": "zao-nginx-config-push",
21+
"name": "zao-nginx-config-push",
22+
"version": "0.2.6",
23+
"publisher": "zaotest",
24+
"targets": [
25+
{
26+
"id": "Microsoft.VisualStudio.Services"
27+
}
28+
],
29+
"description": "Zao's tool for uploading nginx config",
30+
"categories": [
31+
"Azure Pipelines"
32+
],
33+
"icons": {
34+
"default": "images/extension-icon.png"
35+
},
36+
"files": [
37+
{
38+
"path": "src"
39+
}
40+
],
41+
"contributions": [
42+
{
43+
"id": "custom-build-release-task",
44+
"type": "ms.vss-distributed-task.task",
45+
"targets": [
46+
"ms.vss-distributed-task.tasks"
47+
],
48+
"properties": {
49+
"name": "src"
50+
}
51+
}
52+
],
53+
"galleryFlags": [
54+
"Public"
55+
],
56+
"public": false,
57+
"tags":[
58+
"Build task",
59+
"Deploy task"
60+
]
61+
}
62+
63+
```
64+
65+
66+
If this is the first time you are publishing the extension onto the marketplace, make sure the following keys have corresponded and correct value: id, name, publisher, description, icons. Otherwise, if this is just a normal update, all you need to do is just to make sure that the version number is updated to a greater one.
67+
68+
For more details about vss-extension.json, please refer to ([Extension Manifest Reference - Azure DevOps | Microsoft Docs](https://docs.microsoft.com/en-us/azure/devops/extend/develop/manifest?view=azure-devops))
69+
70+
### Step 2. Package the extension
71+
72+
The whole project can be easily packaged by running the following single command:
73+
74+
```
75+
tfx extension create --manifest-globs vss-extension.json
76+
```
77+
78+
Now we will have a .vsix file generated automatically and ready for uploading to the marketplace portal.
79+
80+
If this is the first time you are using this command, you may need to install tfx-cli by:
81+
82+
```
83+
npm install -g tfx-cli
84+
```
85+
86+
### Step 3. Upload the .vsix file onto the marketplace
87+
88+
Sign in the Visual Studio Marketplace Publishing Portal. A normal update will be as easy as clicking the Update button of your extension and drag your .visx generated just now into it.
89+
90+
![Image](images/readme-marketplace.png)
91+
92+
93+
There will be a verification process running as soon as you uploaded the .visx file. Once the verification is completed, the Marketplace Publishing Portal will automatically update your extension to the newest version.
94+
95+
However, if this is the first time you are publishing the pipeline extension, please refer to Step 5: Publish your extension [Add a build or release task in an extension - Azure DevOps | Microsoft Docs](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops#create-your-publisher) to learn about how to create a new publisher account.
96+
97+
98+
## Plan B. Pipelined Update
99+
100+
You can also set up an Azure pipeline to automate the updating and releasing process with the following template:
101+
102+
```
103+
# build.yml
104+
# This is an example pipeline if we need a pipeline to update the task onto the market place
105+
# If we use manual update, this will not be needed.
106+
107+
trigger:
108+
- main
109+
110+
pool:
111+
vmImage: "ubuntu-latest"
112+
113+
variables:
114+
PublisherID:
115+
ExtensionID:
116+
ExtensionName:
117+
ExtensionVersion:
118+
ArtifactStagingDirectory: './artifact'
119+
ArtifactName: 'extension_artifact'
120+
121+
122+
123+
stages:
124+
- stage: Package_extension_and_publish_build_artifacts
125+
jobs:
126+
- job:
127+
steps:
128+
- task: TfxInstaller@3
129+
inputs:
130+
version: "v0.7.x"
131+
- task: Npm@1
132+
inputs:
133+
command: 'install'
134+
workingDir: './src' # Update to the name of the directory of your task
135+
- task: Bash@3
136+
displayName: Compile Javascript
137+
inputs:
138+
targetType: "inline"
139+
script: |
140+
cd src # Update to the name of the directory of your task
141+
tsc
142+
- task: QueryAzureDevOpsExtensionVersion@3
143+
inputs:
144+
connectTo: 'VsTeam'
145+
connectedServiceName: 'release-test-connection' # Change to whatever you named the service connection
146+
publisherId: '$(PublisherID)'
147+
extensionId: '$(ExtensionID)'
148+
versionAction: 'Patch'
149+
outputVariable: 'Task.Extension.Version'
150+
- task: PackageAzureDevOpsExtension@3
151+
inputs:
152+
rootFolder: '$(System.DefaultWorkingDirectory)'
153+
publisherId: '$(PublisherID)'
154+
extensionId: '$(ExtensionID)'
155+
extensionName: '$(ExtensionName)'
156+
extensionVersion: '$(ExtensionVersion)'
157+
updateTasksVersion: true
158+
updateTasksVersionType: 'patch'
159+
extensionVisibility: 'private' # Change to public if you're publishing to the marketplace
160+
extensionPricing: 'free'
161+
- task: CopyFiles@2
162+
displayName: "Copy Files to: $(ArtifactStagingDirectory)"
163+
inputs:
164+
Contents: "**/*.vsix"
165+
TargetFolder: "$(ArtifactStagingDirectory)"
166+
- task: PublishBuildArtifacts@1
167+
inputs:
168+
PathtoPublish: '$(ArtifactStagingDirectory)'
169+
ArtifactName: '$(ArtifactName)'
170+
publishLocation: 'Container'
171+
- stage: Download_build_artifacts_and_publish_the_extension
172+
jobs:
173+
- job:
174+
steps:
175+
- task: TfxInstaller@3
176+
inputs:
177+
version: "v0.7.x"
178+
- task: DownloadBuildArtifacts@0
179+
inputs:
180+
buildType: "current"
181+
downloadType: "single"
182+
artifactName: "$(ArtifactName)"
183+
downloadPath: "$(System.DefaultWorkingDirectory)"
184+
- task: PublishAzureDevOpsExtension@3
185+
inputs:
186+
connectTo: 'VsTeam'
187+
connectedServiceName: 'release-test-connection' # Change to whatever you named the service connection
188+
fileType: 'vsix'
189+
vsixFile: '$(PublisherID).$(ExtensionName)/$(PublisherID)..vsix'
190+
publisherId: '$(PublisherID)'
191+
extensionId: '$(ExtensionID)'
192+
extensionName: '$(ExtensionName)'
193+
updateTasksVersion: false
194+
extensionVisibility: 'private' # Change to public if you're publishing to the marketplace
195+
extensionPricing: 'free'
196+
197+
```
198+
199+
200+
This will allow the pipeline automatically start building the package and update the extension onto the marketplace.
201+
202+
However, in order to enable this pipeline, you may need to:
203+
204+
### Step 1. Create an organization as well as a project on Azure DevOps.
205+
206+
See [Create a project - Azure DevOps | Microsoft Docs](https://docs.microsoft.com/en-us/azure/devops/organizations/projects/create-project?tabs=browser&view=azure-devops).
207+
208+
### Step 2. Install Azure DevOps Extension Task to your Azure DevOps organization.
209+
210+
See [Azure DevOps Extension Tasks - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-developer-tools-build-tasks&targetId=85fb3d5a-9f21-420f-8de3-fc80bf29054b&utm_source=vstsproduct&utm_medium=ExtHubManageList).
211+
212+
### Step 3. Generate a personal access token on Azure DevOps.
213+
214+
This token will be used later when we create a service connection. Configure the authorization scope for the token as follows or refer to [Azure DevOps Extension Tasks - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-developer-tools-build-tasks&targetId=85fb3d5a-9f21-420f-8de3-fc80bf29054b&utm_source=vstsproduct&utm_medium=ExtHubManageList).
215+
216+
![Image](images/readme-personal-access-token.png)
217+
218+
![Image](images/readme-token-scopes.png)
219+
220+
221+
### Step 4. Create a service connection in order to authorize the pipeline’s agent for accessing Visual Studio MarketPlace.
222+
223+
On how to create a service connection, see [Service connections in Azure Pipelines - Azure Pipelines | Microsoft Docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?tabs=yaml&view=azure-devops). Note that you may need to select Visual Studio Marketplace for the service connection type.
224+
225+
![Image](images/readme-service-connections.png)
226+
227+
228+
### Step 5. Compose the .yml file.
229+
230+
After all the previous steps, you are now able to create a build and release pipeline using the template we mentioned at the beginning. This task will be automatically packaged and updated to the marketplace once the pipeline is triggered.

azure_pipeline/example.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trigger:
2+
- main
3+
4+
pool:
5+
vmImage: ubuntu-latest
6+
7+
steps:
8+
- task: nginx-config-push@0
9+
inputs:
10+
serviceConnectionName: '(sercive-connection-name)'
11+
resourceGroupName: '(resource-group-name)'
12+
subscriptionId: '(subscription-id)'
13+
deploymentName: '(deployment-name)'
14+
sourceConfigFolderPath: '(config-folder-file-path)'
15+
targetConfigFolderPath: '/etc/nginx/'
16+
5.63 KB
Loading
37 KB
Loading
82.7 KB
Loading
28.5 KB
Loading
30.7 KB
Loading
71 KB
Loading

0 commit comments

Comments
 (0)