RedJandal
RedJandal

Reputation: 1213

How do I set up continuous integration of a Node.js webjob in VSTS

I am familiar with how to set up continuous integration of node.js web applications using VSTS.

How do I go about setting up continuous integration for a node.js webjob. I have found examples of how to do it with a .NET project using Visual Studio however could not find any documentation on how to do it with a node.js webjob.

Upvotes: 0

Views: 784

Answers (2)

camous
camous

Reputation: 1000

done the following : a build + deploying a nodejs webjob through Azure App Service Deploy task (FTP was stopped due to security issue in our IT landscape).

it's a quick & dirty approach for recovering our build + release process which were at stake, open minded to any other approach, but documentation on this specific topic (as said in the initial question) is fairly inexistant.

in my project, all stuff (run.js + package.json + dependencies are at root level)

Build definition enter image description here

  1. Get Sources
  2. powershell script inline (cleanup destination folder, create destination folder, move root folder to webjob structure)
Remove-Item -Path $(Build.BinariesDirectory)\app_data -Force -Confirm:$false -Recurse -ErrorAction:Ignore
New-Item $(Build.BinariesDirectory)\app_data\jobs\continuous\ -ItemType Directory -Force
Move-Item $(Build.SourcesDirectory)\[webjobname]\ $(Build.BinariesDirectory)\app_data\jobs\continuous\[webjobname] -Force
  1. npm install within $(Build.BinariesDirectory)\app_data\jobs\continuous\[webjobname] (working folder)

  2. Archive task $(Build.BinariesDirectory)

  3. Publish artifact $(Build.ArtifactStagingDirectory) (path to publish)

Release definition: classic App Service Deploy using artifact zip file generated by above build

Upvotes: 1

Marina Liu
Marina Liu

Reputation: 38096

To CI build your node.js app, you can manage your code by a repo on VSTS firstly (or remote repo hosted on other sites such as github, bitbucket ect), then create a build definition definition for your node.js webjob. Detail steps as below:

1. Manage code by VSTS repo (git or TFVC)

You can manage your node.js app to a current repo you used or you can create a new repo to manage your node.js app. Create a new git repo (I use git repo as example, similar with TFVC), you can refer create a git repo for team project.

Push your node.js code to VSTS repo. You can use VS (clone the repo -> copy your code in local repo -> commit -> push) or git commands directly.

2. Create CI build

In Builds Tab -> New -> use the Node.JS With Gulp (PREVIEW) template (or you can use empty template and then add tasks manually) -> Get sources step -> specify repo and branch which your code exists -> specify settings for tasks -> add other tasks if you need -> Triggers Tab -> enable Continuous Integration. enter image description here

More details for node.js app CI build, you can refer define your CI build for node.js app.

3. Add your app in Azure webjobs

In the CI build definition, add below tasks:

  • Copy files task: to copy the App you want to run on Azure webjobs from $(System.DefaultWorkingDirectory) to $(Build.ArtifactStagingDirectory).

  • Archive Files task: create a zip file (such as $(Build.ArtifactStagingDirectory)/webjob.zip) from files in $(Build.ArtifactStagingDirectory).

  • Azure App Service Deploy task: deploy your zip file ($(Build.ArtifactStagingDirectory)/webjob.zip) to Azure.

And more details, you can also refer this thread.

Upvotes: 0

Related Questions