VSTS TFS CI/CD With Functionize · achieve this. This modern practice enables them to safely build,...
Transcript of VSTS TFS CI/CD With Functionize · achieve this. This modern practice enables them to safely build,...
VSTS TFS CI/CD With FunctionizeOverview
Preface
The benefits of Continuous Integration are tremendous when automation plays an
integral part of your workflow. Functionize integrates with your current software
development cycle, where you can test your UI with Functionize within your pipelines &
stages.
Across almost every industry, the companies that are most likely to succeed are the
ones who make great software. Because of this, it is important that development teams
optimize their operations for efficiency, quality, and operability. Continuous integration,
continuous deployment, and continuous delivery is a trending topic for developers to
achieve this. This modern practice enables them to safely build, test, and deploy their
code. A CI system can automatically deploy code to staging or production once all of the
tests are passing.
Creating and maintaining test scripts within the automatic verification system of a CI
software has been a costly bottleneck for the CI/CD process. Integrating Functionize’s
automated testing solution into the CI workflow will solve this problem and enable an
even more optimized devops cycle.
Learn more at:
www.functionize.com
Workflow
Prerequisites
• Functionize Account - Client ID (link)
• Functionize Account - Secret Key (link)
• Working Staging/Beta Domain - needed to record and execute Functionize
test cases. ( We are using Heroku in this example. )
• Functionize project with pre built Orchestration running against the url
above - Deployment ID (link).
• Declare Secret Variables in TFS Build Stage.
https://gitlab.com/user/project/settings/ci_cd
Learn more at:
www.functionize.com
Replicating Workflow
Project Tree
• [Optional, If using Heroku or Container Based Deployment.]Working nginx/
Apache/Tomcat root directory. For example: /usr/share/nginx/html/staging.
functionize.com/<Files>, In which git/mercurial already setup, We just need
to pull latest code in that repo with “git pull” or “hg pull”.
• You may fork this repo to clone our sample codebase- Github Repo
TFS CI repo contain Sample Build.json, which you can import to replicat whole build.
Learn more at:
www.functionize.com
Importing Sample Build in
After Import It will look like this:
Learn more at:
www.functionize.com
Understating Our Complete Build Workflow
The complete workflow is divided into 5 stages explained in detail in the following section
- Gitlab also allows one to have a high level view of how the stages are connected to each
other.
Stages Views In Gitlab CI/CD DashBoard
Learn more at:
www.functionize.com
Sample Build.json file
Stages:
{ “version”: “0.3”, “definition”: { “build”: [ { “environment”: {}, “enabled”: true, “continueOnError”: false, “alwaysRun”: false, “displayName”: “Lint CSS”, “timeoutInMinutes”: 0, “task”: { “id”: “d9bafed4-0b18-4f58-968d-86655b4d2ce9”, “versionSpec”: “2.*”, “definitionType”: “task” }, “inputs”: { “script”: “npm install && ./node_modules/gulp/bin/gulp.js lint-css”, “workingDirectory”: “”, “failOnStderr”: “false” } } ], “options”: [ { “enabled”: true, “definition”: { “id”: “5d58cc01-7c75-450c-be18-a388ddb129ec” }, “inputs”: { “branchFilters”: “[\”+refs/heads/*\”]”, “additionalFields”: “{}” } }, { “enabled”: false, “definition”: { “id”: “a9db38f9-9fdc-478c-b0f9-464221e58316” }, “inputs”: { “workItemType”: “1625740”, “assignToRequestor”: “true”, “additionalFields”: “{}” } } ], “triggers”: [ { “branchFilters”: [ “+refs/heads/master” ], “pathFilters”: [], “batchChanges”: false, “maxConcurrentBuildsPerBranch”: 1, “pollingInterval”: 0, “triggerType”: 2 } ], “variables”: { “HEROKU_API_KEY”: { “value”: “6475eb75-777f-4013-88ae-d7f30dbb22d3” }, “system.debug”: { “value”: “true”, “allowOverride”: true } }, “retentionRules”: [ { “branches”: [ “+refs/heads/*” ], “artifacts”: [], “artifactTypesToDelete”: [ “FilePath”, “SymbolStore” ], “daysToKeep”: 10, “minimumToKeep”: 1, “deleteBuildRecord”: true, “deleteTestResults”: true } ], “_links”: { “self”: {
Learn more at:
www.functionize.com
“href”: “https://functionize.visualstudio.com/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4/_apis/build/Definitions/1?revision=81” }, “web”: { “href”: “https://functionize.visualstudio.com/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4/_build/definition?definitionId=1” }, “editor”: { “href”: “https://functionize.visualstudio.com/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4/_build/designer?id=1&_a=edit-build-definition” }, “badge”: { “href”: “https://functionize.visualstudio.com/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4/_apis/build/status/1” } }, “buildNumberFormat”: “$(date:yyyyMMdd)$(rev:.r)”, “jobAuthorizationScope”: 1, “jobTimeoutInMinutes”: 60, “jobCancelTimeoutInMinutes”: 5, “repository”: { “properties”: { “cleanOptions”: “0”, “labelSources”: “0”, “labelSourcesFormat”: “$(build.buildNumber)”, “reportBuildStatus”: “true”, “gitLfsSupport”: “false”, “skipSyncSource”: “false”, “checkoutNestedSubmodules”: “false”, “fetchDepth”: “0” }, “id”: “cb43d107-fbd6-4511-a264-518e19f08cb2”, “type”: “TfsGit”, “name”: “MS_Project”, “url”: “https://functionize.visualstudio.com/MS_Project/_git/MS_Project”, “defaultBranch”: “refs/heads/master”, “clean”: “false”, “checkoutSubmodules”: false }, “processParameters”: {}, “quality”: 1, “authoredBy”: { “displayName”: “Rahul sharma”, “url”: “https://app.vssps.visualstudio.com/Acc9b637a-031e-45dc-a7e7-27d109ea4e67/_apis/Identities/4b4922b3-214d-6413-b586-374450498189”, “_links”: { “avatar”: { “href”: “https://functionize.visualstudio.com/_apis/GraphProfile/MemberAvatars/aad.NGI0OTIyYjMtMjE0ZC03NDEzLWI1ODYtMzc0NDUwNDk4MTg5” } }, “id”: “4b4922b3-214d-6413-b586-374450498189”, “uniqueName”: “[email protected]”, “imageUrl”: “https://functionize.visualstudio.com/_api/_common/identityImage?id=4b4922b3-214d-6413-b586-374450498189”, “descriptor”: “aad.NGI0OTIyYjMtMjE0ZC03NDEzLWI1ODYtMzc0NDUwNDk4MTg5” }, “drafts”: [], “queue”: { “_links”: { “self”: { “href”: “https://functionize.visualstudio.com/_apis/build/Queues/3” } }, “id”: 3, “name”: “Hosted Linux Preview”, “url”: “https://functionize.visualstudio.com/_apis/build/Queues/3”, “pool”: { “id”: 3, “name”: “Hosted Linux Preview”, “isHosted”: true } }, “id”: 1, “name”: “MS_Project-Docker container-CI”, “url”: “https://functionize.visualstudio.com/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4/_apis/build/Definitions/1?revision=81”, “uri”: “vstfs:///Build/Definition/1”, “path”: “\\”, “type”: 2, “queueStatus”: 0, “revision”: 81, “createdDate”: “2018-08-22T04:37:55.770Z”, “project”: { “id”: “fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4”, “name”: “MS_Project”, “url”: “https://functionize.visualstudio.com/_apis/projects/fff2016c-2a4a-4ec4-a1ea-995fa0b11dc4”, “state”: “wellFormed”, “revision”: 9, “visibility”: 0 } }, “metaData”: { “customTasks”: [], “serviceEndpoints”: [] }}
Learn more at:
www.functionize.com
STAGE 1: Lint-css Validation
STAGE-2: Lint-js Validation
STAGE 3: Deploy Staging Codebase
TFS provides us views of a running stage as described below :
A. Pipeline View:
This stage runs a syntax validator on the CSS files in the target codebase to be deployed.
A. Pipeline View
This stage push the code to Heroku app using dpl gem.
A. Pipeline View:
Learn more at:
www.functionize.com
STAGE 4: Functionize Automation Testing
This is the main stage where the Functionize integration takes place in the workflow - it is
used to remotely kick off a pre built Functionize Orchestration (an automated test suite of
tests built on the staging environment url as defined above). This stage waits for a result
back from the Functionize platform regarding the success or failure of the orchestration,
and makes a decision accordingly on whether to proceed with the production deployment
of the new codebase.
functionize-cli - This is a command line tool developed by Functionize to remotely
manage and operate a client account - including projects, orchestrations and test cases.
Its dependencies include nodejs, - hence the commands above to install associated
dependencies using “npm install ” & “npm install -g”.
You can get more information about the Functionize command line tool functionize-cli
here .
You will need to use the YOUR_API_KEY, YOUR_SECRET_KEY, and PROJECT_
DEPLOYMENT_ID, referenced at the beginning of this document.
The two views of this stage in Gitlab are presented below:
A. Pipeline View
Learn more at:
www.functionize.com
B. Detailed Execution Code view:
Upon the completion of this stage, there can be two possible results for the executed
Functionize Orchestration:
A. Successful Orchestration Execution: The Orchestration ran successfully and all tests in the test suite passed successfully, as
can be noticed in the image above. In this scenario, the workflow pipeline will continue on
to the next step.
B. Failed Orchestration Execution: The Orchestration did not run successfully and one or more tests in the test suite failed,
leading to a failed message, as can be noticed in the images below. In this scenario, the
workflow pipeline will not continue on to the next step, and will halt at this stage with an
error message.
© Copyright 2018 Functionize, Inc. All Rights Reserved 156 2nd Street | San Francisco, CA 94105 +1-800-826-5051 | www.functionize.com
STAGE 5: Deploy Production Codebase
Upon successful completion of the previous stage, we are now ready to push the verified
codebase over to the production environment. This stage pulls the code from the sample
git repository and deploys it to the production servers, and makes the new changes
publicly accessible.
The two views of this stage in Gitlab are presented below :
A. Pipeline View
Once this last stage is completed, all the latest changes in the verified codeset should be
available on the production environment URL.