未加星标

CI/CD Pipeline for Angular2 with VSTS.

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

“Zero touch testing and deployments” is a common DevOps mantra for your continuous integration and continuous deployment (CI/CD) pipeline. Also for you frontend projects.

In this post a how to use and configure Visual Studio Team Services for this CI/CD practice on Angular2 projects. Continue reading and/or watch this overview video:

The Angular2 Project.

The time where you simply had to copy a javascript file to a server is over. There are many steps to take to prepare an Angular project for production. With TypeScript we need some compiling, we need to make it work for many versions with Shims, the JavaScript files needs to get bundeled, uglified, minified, validated and so on… and, we need to test the script on quality with unit-tests, UI-tests and coverage.

The heavy lifting and thinking of setting up all these libraries and tasks is already done by the contributors of this Angular2 Seed project .


CI/CD Pipeline for Angular2 with VSTS.

After cloning this GitHub project getting it up and running in VSTS is easy. First run it local and make sure you have Java installed for Selenium.

Setup Visual Studio Team Services. GIT and GitGFlow

After creating a VSTS account and a scrum project with GIT as versioning system, you can configure the branches with policies. See: Gitflow and VSO branch policies use them together and the VSTS documentation .

Build Agent

For the build system you need to create a custom build agent, during the build there is interaction with the UI and I use the Chrome browser for testing.

A perfect place to host this Build Agent VM is in Azure DevTest Labs. It takes care of the artifacts needed on the Build Agent and the schedule to start stop the VM. See this Channel9 video (in Dutch) andthis Post.


CI/CD Pipeline for Angular2 with VSTS.

The build agent is configured to run interactively , to make sure interaction with the UI is allowed. To make sure all the PATH variables are correct I start the Build Agent via the Node Command Line.


CI/CD Pipeline for Angular2 with VSTS.

And also make sure Java is installed for running selenium.

Builds.

Per branch two builds are configured, one which is activated by the Pull Request Branch Policy and the other at Integration when a Pull Request is approved. Four builds per Git repo (at start).


CI/CD Pipeline for Angular2 with VSTS.

The CI build activates the deployment of the Angular2 App and has some more steps, like packages and run UI test. For the PR Build a minimal set of steps is configured, to make the build execute as fast as possible.

The PR Build has the steps to build the solution and run the unit tests in the project.


CI/CD Pipeline for Angular2 with VSTS.

These steps are executed via the NPM Test command, which executes the Gulp Test task.


CI/CD Pipeline for Angular2 with VSTS.
CI/CD Pipeline for Angular2 with VSTS.

This is all default available in the Seed Project, only one additional task and customization is done for getting the Unit Test results in VSTS. In the karma.conf.js a trx reporter is added for output to trx.


CI/CD Pipeline for Angular2 with VSTS.

And in the VSTS Build this output is published to VSTS.


CI/CD Pipeline for Angular2 with VSTS.

This will make the Unit Test results appear in VSTS.


CI/CD Pipeline for Angular2 with VSTS.

The CI Build has some more steps, next to the Get Deploy Tools (see next paragraph) and the Unit Test execution it also builds the Angular2 Project and makes it deployment ready.


CI/CD Pipeline for Angular2 with VSTS.

This Build production activity is also already baked in the Angular2 Seed project in the GulpFile.ts.


CI/CD Pipeline for Angular2 with VSTS.

Next the Gulp e2e task (also already there) will execute the Selenium Protractor UI tests. Also here only one customization is done to get the result in VSTS. The jasmine-trx-reporter is added as a report.


CI/CD Pipeline for Angular2 with VSTS.

Which is published in VSTS via the Publish test result step.


CI/CD Pipeline for Angular2 with VSTS.
Deploy the Angular2 App.

The Angular Application will land on Azure Web Apps. After creating this Web App via the Azure portal (normal done with ARM) and the three deployment slot (dev, test and staging), the deployment via VSTS Release can be configured.

For the deployment the published build artifacts from the CI build are used. As a deployment mechanism MSDeploy is used via PowersHell, where the parameters are coming from the PublishSettings file, downloaded from the Azure Portal.

cmd.exe /C $("msdeploy.exe -source:IisApp='$wwwroot' -dest:IisApp='$websiteName',computerName='https://$publishURL/msdeploy.axd',userName='$userName',password='$password',authtype='Basic',includeAcls='False' -verb:sync -enableLink:contentLibExtension -enableRule:AppOffline -retryAttempts:2")

This PowerShell file is made available for VSTS release via the build step GetDeployTools. The powershell script requires two parameters, the PublishSettingsFile and the build drop location.


CI/CD Pipeline for Angular2 with VSTS.

Per Git repo there are two release activities, one for the develop branch and one for the master branch. The develop branch only pushes releases to the development and test deployment slots and the master release also to the staging and production after approval.


CI/CD Pipeline for Angular2 with VSTS.

And all of this results in a nice controlled CI/CD release pipeline, and again the heavy thinking and work already is done by the contributors of the Angular2 Seed project.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

分页:12
转载请注明
本文标题:CI/CD Pipeline for Angular2 with VSTS.
本站链接:http://www.codesec.net/view/483986.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(37)