You hear about companies like Amazon and Google deploying code thousands of times a day. While your organization may not require that level of frequency, you no doubt need the ability to innovate rapidly. And thanks to cloud and DevOps, these privileges aren’t available only to the unicorns.
Here at nClouds, as part of every transformation initiative, we use continuous integration (CI) and continuous delivery (CD) processes and tools – CI/CD pipelines – to enable customer teams to deliver code changes more frequently and reliably. CI provides a consistent and automated way to build, package, and test applications. CD automates the delivery of applications to infrastructure environments. We consider CI/CD pipelines the cost of entry for optimizing your AWS cloud infrastructure.
One of the decisions you need to make is which CI/CD tool to use—and there are many good ones. In this blog post, we’ll talk briefly about the benefits of CI/CD as well as some of the popular tools available. And we’ll drill into Travis CI to show you how to build a CI/CD pipeline. Watch for future posts on other tools, including AWS CodePipeline and CircleCI.
In today’s competitive market, your success depends on how quickly you can innovate. From our experience, many organizations waste time battling with deployment-related issues – time that could be spent delivering value to end customers.
The foundation of innovation is a CI/CD pipeline that enables development teams to deliver code changes more frequently and reliably in a sustainable way. It’s all about speeding time to market by shortening the development lifecycle while keeping software deployable throughout the cycle.
How do you achieve this speed? By applying automation to delivery and testing of builds, to integration tests for new commits, as well as to deployment and release of software versions. CI/CD enables rapid feedback on code issues, which not only speeds your process but also results in improved software quality.
For example, a startup can use rapid prototyping to try out a technology stack against the existing infrastructure and see how a system will perform without actually having to build it. In this way, you can quickly validate your features and avoid possible bottlenecks and risks.
Here are some reasons you should care:
At nClouds, we use a variety of CI tools such as Travis CI, CircleCI, and Jenkins. We also use release orchestration/analytics tools like AWS CodePipeline, deployment tools like AWS CodeDeploy, and configuration tools like Ansible, Chef, and Terraform.
As a result, our customers can:
How do we decide which tool to use? It depends on the needs of the development team for a project. There are a number of factors to consider – here are a few:
Some of the key capabilities of Travis CI that we particularly like:
We often use Travis CI to automate deployment to the AWS account. In such a case, Travis CI is triggered to automate the ECS cluster update or trigger AWS CloudFormation templates. How do we do this? Here’s the step-by-step process:
Sources: Breaking the build and Deploying your code in Travis CI documentation.
To deploy on Amazon ECS using secure keys and environment variables, use the AWS Command Line Interface (CLI) to assign an AWS Identity and Access Management (AWS IAM) policy to an IAM user. For this setup, we need to add some secrets on Travis CI, which are the access keys to the AWS account for our Travis CI user. Travis CI will always hide the values of secret variables even if you attempt to show them in the output.
Source: Travis CI documentation, “Defining variables in repository settings.”
Once we have the environment variables set on Travis CI, we can continue with the AWS CLI commands as follows:
aws ecs list-tasks --cluster $CLUSTER_NAME --service-name $SERVICE_NAME --query 'taskArns' --output text
aws ecs describe-services --region $AWS_DEFAULT_REGION --cluster ${CLUSTER_NAME} --service $SERVICE_NAME
aws ecs describe-task-definition --task-definition $TASK_NAME --region $AWS_DEFAULT_REGION
aws ecs register-task-definition --region $AWS_DEFAULT_REGION --family $TASK_NAME --container-definitions "$CONTAINER_DEFINITIONS" --task-role-arn "$TASK_ROLE_NAME"
aws ecs update-service --region $AWS_DEFAULT_REGION --cluster ${CLUSTER_NAME} --service $SERVICE_NAME --task-definition $TASK_ARN
aws ecs run-task --cluster $CLUSTER_NAME --task-definition $TASK_NAME
We can configure this script in one executable file in the Travis file as follows:
before_deploy: "echo 'ready?'"
deploy:
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then ./deploy.sh; fi'
after_deploy:
- ./after_deploy_1.sh
Source: Running commands before and after deploy in Travis CI documentation.
notifications:
slack:
rooms:
- :#development
- :#general
on_success: change # default: always
on_failure: always # default: always
Source: Configuring slack notifications in Travis CI documentation.
jobs:
include:
- stage: run tests
script:
- exec_ios_test.sh
- stage: run tests
script:
- exec_webgl_test.sh
- stage: build app
script: ./build-app-for-webgl.sh
Source: How to define build stages in Travis CI documentation.
language: python
matrix:
include:
- name: "3.5 Unit Test"
python: "3.5"
env: TEST_SUITE=suite_3_5_unit
- name: "3.5 Integration Tests"
python: "3.5"
env: TEST_SUITE=suite_3_5_integration
- name: "pypy Unit Tests"
python: "pypy"
env: TEST_SUITE=suite_pypy_unit
script: ./test.py $TEST_SUITE
Source: Naming jobs within matrices in Travis CI documentation.
To learn more about how nClouds collaborates with our customers using CI/CD pipelines to build sustainable systems for delivering quality software faster, take a look at our DevOps Consulting Services page and nClouds customer cases studies.
We’d love to hear from you…
What tools are you using to automate CI/CD? How have those tools helped your company innovate? Share your thoughts and tips in the Comments section below.
https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system
https://docs.travis-ci.com/user/reference/windows/
https://docs.travis-ci.com/user/languages/
https://docs.travis-ci.com/user/reference/osx/#os-x-version
https://docs.travis-ci.com/user/job-lifecycle/#the-job-lifecycle
https://docs.travis-ci.com/user/job-lifecycle/#breaking-the-build
https://docs.travis-ci.com/user/notifications/
Top takeaways: AWS Managed Microsoft AD and Microsoft Active Directory
2022-12-05 15:25:16