SlideShare a Scribd company logo
CI/CD with GitHub, Travis CI,
SonarCloud and Docker Hub
How to include CICD into your GitHub project
This work is licensed under the Creative Commons Attribution Non Commercial Share Alike 3.0 License. To view a copy of this license, visit
https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco,
California, 94105, USA.
Hands-on
Preparation
,
Requisites
GITHUB
 Docker Hub account
TRAVIS
 Access to Travis with your GitHub account
DOCKER
 GitHub account
CODECOV
 Access to CodeCov with your GitHub account (optional)
SONARCLOUD
 Access to SonarCloud with your GitHub account
Requisites
IDE FORMATTER
 Use a formatter in your IDE.
 This is an example for Eclipse. Import in the Java Preferences
 To apply Ctrl+A and Ctrl+Shift+F. To disable the formatting:
// @formatter:off
// @formatter:on
Requisites
IDE XML INDENTANTION
 Use XML indentation in your IDE.
 XML indentation of 4 spaces. XML Preferences. XML
Editor
Steps
FROM THE BEGINNING
 Fork spring-boot-template repository
 Carefully read the README file and the slides
 Check all the files to be changed mentioned in the Initial
Configuration and use the same value to replace the same
strings
 Use a useful formatter and XML indentation 4.
Initial Configuration
Variables to configure
Variablesto
configure
GITHUB
 Modify the repo badges and description in README
 Create a new branch “release” starting from “master”
 Modify DISCLAIMER and LICENSE-AGREEMENT (EULA)
(Substitute **Spring Template** string by your project).
Check the license and terms
TRAVIS
 Modify the GitHub repo in .travis/prepare.sh script. Find
and replace spring-boot-template string
 Have a look at .travis/push.sh and settings.xml to know
the environment variables used
Variablesto
configure
POM (BEFORE IMPORTING IN THE IDE)
 Find and replace spring-boot-template string
 SCM section. Include the proper GitHub repo
 ArtifactId and version (if applicable)
 Name, description and final name
CHANGELOG
 Add the proper title and description of the repo
CHANGELOG.md and changelog.mustache
 Modify the GitHub Api in changelog.json file. Find and
replace spring-boot-template string
DOCKER
 Find and replace spring-boot-template string
GitHub
Source Code Management
GitHub
Configuration
 Create a Personal Access Token
GitHub
Configuration
 Protect ‘master’ and ‘release’ branches
GitHub
MasterConfiguration
 Configure ‘master’ branch to check Travis before
merging
GitHub
MasterConfiguration
 Configure ‘master’ branch to check Travis before
merging
GitHub
MasterConfiguration
 Configure ‘release’ branch to restrict who can push
Travis CI
Automation Server
TravisCI
Whatis
 Travis CI is an automation server freely available for
open source projects with a couple of clicks and small
file configuration (.travis.yml).
TravisCI
.travis.yml
 Travis CI runs the CI (clean, test, package and sonar goals) when we merge features into master
and runs the CD (release) when push to release.
 A complete .travis.yml example is here:
language: java
sudo: false # faster builds
cache:
directories:
- $HOME/.m2
env:
global:
- secure: “
addons:
sonarcloud:
organization: "arihealth“
token:
secure: xxxx=
script:
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then mvn clean test; mvn package -
Dmaven.test.skip=true; mvn sonar:sonar; fi
- if [ "$TRAVIS_BRANCH" = "master" ]; then mvn clean test; mvn sonar:sonar; fi
- if [ "$TRAVIS_BRANCH" = "release" ]; then chmod +x .travis/prepare.sh &&
.travis/prepare.sh; mvn -s .travis/settings.xml -B release:clean release:prepare; git
push --tags; mvn -s .travis/settings.xml -B release:perform; chmod +x .travis/push.sh &&
.travis/push.sh; fi
TravisCI
EnablingCI
 Access https://travis-ci.org with your GitHub account
 Browse the public Projects
 Enable the GitHub repository (it should contain the
.travis.yml file)
TravisCI
Configuringthehooks
 Travis must be executed in PRs and Push actions. Enable
both options
 The script ignores branches distinct from master and
release
TravisCI
Environmentvariables
 Travis CI has an elegant way to configure secrets using
environment variable
 Add the environment variables. They are used inside
the maven settings.xml and prepare.sh included in
folder .travis. Have a look at them.
TravisCI
Encryptingvariables
 With Travis CI we can encrypt the environment variables
 Please note that encrypted environment variables are not
available for pull requests from forks.
 The encrypted values can be added by anyone, but are only
readable by Travis CI
 This way we can reuse them inside the .travis.yml file
 For Windows Ruby gem can be downloaded from rubyinstaller
 To include encrypted variables into .travis.yml
 gem install travis
 travis encrypt SOMEVAR=“secretvalue” –add
 Further information here
 Remember that encryption is done at repository level, so you need
to encrypt again your variables
CodeCov
Code Coverage
CodeCov
 Open source code test coverage
 Access https://codecov.io/ using your GitHub credentials
 No need to enable the GitHub repo as Travis CI, but
Jacoco (or similar enabled)
 Add the following snippet to your .travis.yml
after_success:
- bash <(curl -s https://codecov.io/bash)
SonarCloud
Quality Analysis
SonarCloud
Configuration
 Follow using SonarCloud with Travis CI guidelines
1. Create a user authenticated token for your account in
SonarCloud with your GitHub account
2. Encrypt this token travis encrypt abcdef0123456789 or
define SONAR_TOKEN in your Repository Settings.
SonarCloud
EnableGitHubrepos
3. Find which SonarCloud.io organization you want to push
your project on and get its key
SonarCloud
EnableGitHubrepos
3. Find which SonarCloud.io organization you want to push
your project on and get its key and add the project.
SonarCloud
EnableGitHubrepos
3. Find which SonarCloud.io organization you want to push
your project on and get its key
SonarCloud
EnableGitHubrepos
4. Add this snippet to your .travis.yml file:
addons:
sonarcloud:
organization: "arihealth"
token:
secure: “***********”
 script:
 - if [ "$TRAVIS_BRANCH" = "master" &&
"$TRAVIS_PULL_REQUEST" = true ]; then mvn clean
 test; mvn package -Dmaven.test.skip=true; mvn sonar:sonar
–Dsonar.projectKey=arihealth_spring-boot-template;
Docker Hub
Public Docker Registry
DockerHub
Whatis
 Open source repository of Docker images
 You need an account at https://hub.docker.com/
 You can create an organization for your Lab or department
 Allow access permission in your GitHub account
DockerHub
Configuration
 Link your GitHub account to Docker at My Profile/Edit
profile, this is needed for the Automatic builds
DockerHub
GitHub–AuthorizedOauthApps
 Check the Authorized OAuth Docker Hub Builder
Application in GitHub
DockerHub
Createanewrepository
 Click “Repositories” and “Create Repository +”
 Select the GitHub account Connected and the user and repo to link
(in case you have organizations)
 Then “Click here to customize the build settings” for the Automatic
Builds
 In “Build Rules”
 Generate a Docker Tag “{sourceref}” version from Source
Type “Tag” and the Source is “/^[0-9.]+$/” (any semver
version). Which means when a new tag is generated in
GitHub (during the Continuous Delivery workflow)
 Generate a Docker Tag “latest” version from Source Type
“Branch” and Source “release”
 Release branch receives pushes only when a new version is
generated
DockerHub
Createanewrepository
 Automatic Builds can be modified in the “Builds” section of
the image “Configure Automatic Builds” button
DockerHub
Builds
Material
 https://github.com/AriHealth/spring-boot-template
 https://dzone.com/articles/applying-cicd-to-java-apps-
using-spring-boot
 https://docs.travis-ci.com/user/languages/java/
 https://coderwall.com/p/9b_lfq/deploying-maven-artifacts-
from-travis
 https://github.blog/2013-05-16-personal-api-tokens/
 https://github.com/settings/tokens/
 https://docs.travis-ci.com/user/sonarcloud/
 https://stackoverflow.com/questions/58821867/how-to-
share-credentials-used-in-travis-ci
 https://docs.travis-ci.com/user/environment-variables/
 https://docs.travis-ci.com/user/encryption-keys/#usage
Thanks!
For more information please contact:
carlos.cavero@atos.net

More Related Content

What's hot

Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
Kong Inc.
 
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
NaimishKakkad2
 
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CISecure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Mitchell Pronschinske
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
Josef Adersberger
 
Flexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with KongFlexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with Kong
Sven Bernhardt
 
Reactive messaging Quarkus and Kafka
Reactive messaging Quarkus and KafkaReactive messaging Quarkus and Kafka
Reactive messaging Quarkus and Kafka
Bruno Horta
 
Serverless Apps with Open Whisk
Serverless Apps with Open Whisk Serverless Apps with Open Whisk
Serverless Apps with Open Whisk
Dev_Events
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
Yohann Ciurlik
 
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
CodeOps Technologies LLP
 
[Lakmal] Automate Microservice to API
[Lakmal] Automate Microservice to API[Lakmal] Automate Microservice to API
[Lakmal] Automate Microservice to API
Lakmal Warusawithana
 
How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)
Krishna-Kumar
 
Modern application delivery with Consul
Modern application delivery with ConsulModern application delivery with Consul
Modern application delivery with Consul
Mitchell Pronschinske
 
Shift Left - How to improve your security with checkov before it’s going to p...
Shift Left - How to improve your security with checkov before it’s going to p...Shift Left - How to improve your security with checkov before it’s going to p...
Shift Left - How to improve your security with checkov before it’s going to p...
Anton Grübel
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
Amazon Web Services
 
API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and Docker
Apigee | Google Cloud
 
Manage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API GatewayManage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API Gateway
Thibault Charbonnier
 
Deploying Anything as a Service (XaaS) Using Operators on Kubernetes
Deploying Anything as a Service (XaaS) Using Operators on KubernetesDeploying Anything as a Service (XaaS) Using Operators on Kubernetes
Deploying Anything as a Service (XaaS) Using Operators on Kubernetes
All Things Open
 
HashiTalks 2020 - Chef Tools & Terraform: Better Together
HashiTalks 2020 - Chef Tools & Terraform: Better TogetherHashiTalks 2020 - Chef Tools & Terraform: Better Together
HashiTalks 2020 - Chef Tools & Terraform: Better Together
Matt Ray
 
Microservices in GO lang
Microservices in GO langMicroservices in GO lang
Microservices in GO lang
SHAKIL AKHTAR
 
Creating a Kubernetes Operator in Java
Creating a Kubernetes Operator in JavaCreating a Kubernetes Operator in Java
Creating a Kubernetes Operator in Java
Rudy De Busscher
 

What's hot (20)

Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
 
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
Deep Dive on Continuous Integration and Continuous Delivery in Anypoint Platf...
 
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CISecure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 
Flexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with KongFlexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with Kong
 
Reactive messaging Quarkus and Kafka
Reactive messaging Quarkus and KafkaReactive messaging Quarkus and Kafka
Reactive messaging Quarkus and Kafka
 
Serverless Apps with Open Whisk
Serverless Apps with Open Whisk Serverless Apps with Open Whisk
Serverless Apps with Open Whisk
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
 
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
Containers and Developer Defined Data Centers - Evan Powell - Keynote in Bang...
 
[Lakmal] Automate Microservice to API
[Lakmal] Automate Microservice to API[Lakmal] Automate Microservice to API
[Lakmal] Automate Microservice to API
 
How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)How to contribute to cloud native computing foundation (CNCF)
How to contribute to cloud native computing foundation (CNCF)
 
Modern application delivery with Consul
Modern application delivery with ConsulModern application delivery with Consul
Modern application delivery with Consul
 
Shift Left - How to improve your security with checkov before it’s going to p...
Shift Left - How to improve your security with checkov before it’s going to p...Shift Left - How to improve your security with checkov before it’s going to p...
Shift Left - How to improve your security with checkov before it’s going to p...
 
Build CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation SlidesBuild CICD Pipeline for Container Presentation Slides
Build CICD Pipeline for Container Presentation Slides
 
API Microservices with Node.js and Docker
API Microservices with Node.js and DockerAPI Microservices with Node.js and Docker
API Microservices with Node.js and Docker
 
Manage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API GatewayManage your APIs and Microservices with an API Gateway
Manage your APIs and Microservices with an API Gateway
 
Deploying Anything as a Service (XaaS) Using Operators on Kubernetes
Deploying Anything as a Service (XaaS) Using Operators on KubernetesDeploying Anything as a Service (XaaS) Using Operators on Kubernetes
Deploying Anything as a Service (XaaS) Using Operators on Kubernetes
 
HashiTalks 2020 - Chef Tools & Terraform: Better Together
HashiTalks 2020 - Chef Tools & Terraform: Better TogetherHashiTalks 2020 - Chef Tools & Terraform: Better Together
HashiTalks 2020 - Chef Tools & Terraform: Better Together
 
Microservices in GO lang
Microservices in GO langMicroservices in GO lang
Microservices in GO lang
 
Creating a Kubernetes Operator in Java
Creating a Kubernetes Operator in JavaCreating a Kubernetes Operator in Java
Creating a Kubernetes Operator in Java
 

Similar to CICD With GitHub, Travis, SonarCloud and Docker Hub

Jump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & GithubJump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & Github
hubx
 
PVS-Studio in the Clouds: Travis CI
PVS-Studio in the Clouds: Travis CIPVS-Studio in the Clouds: Travis CI
PVS-Studio in the Clouds: Travis CI
Andrey Karpov
 
Attacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous DeliveryAttacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous Delivery
James Wickett
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
Saeed Hajizade
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
Juraj Hantak
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?
Rsquared Academy
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3
Velocidex Enterprises
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environments
alexandru giurgiu
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
Amazon Web Services
 
How to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsHow to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy steps
Deveo
 
DevNet Associate : Python introduction
DevNet Associate : Python introductionDevNet Associate : Python introduction
DevNet Associate : Python introduction
Joel W. King
 
Integrating security testing into your container build pipeline - SDD308 - AW...
Integrating security testing into your container build pipeline - SDD308 - AW...Integrating security testing into your container build pipeline - SDD308 - AW...
Integrating security testing into your container build pipeline - SDD308 - AW...
Amazon Web Services
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
Vincent De Smet
 
Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)
Bohdan Dovhań
 
Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17
Excelian | Luxoft Financial Services
 
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMasterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Malcolm Duncanson, CISSP
 
Jbossworld Presentation
Jbossworld PresentationJbossworld Presentation
Jbossworld Presentation
Dan Hinojosa
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
Vino Harikrishnan
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 

Similar to CICD With GitHub, Travis, SonarCloud and Docker Hub (20)

Jump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & GithubJump into Squeak - Integrate Squeak projects with Docker & Github
Jump into Squeak - Integrate Squeak projects with Docker & Github
 
PVS-Studio in the Clouds: Travis CI
PVS-Studio in the Clouds: Travis CIPVS-Studio in the Clouds: Travis CI
PVS-Studio in the Clouds: Travis CI
 
Attacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous DeliveryAttacking Pipelines--Security meets Continuous Delivery
Attacking Pipelines--Security meets Continuous Delivery
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environments
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
How to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy stepsHow to create a local Android open source project mirror in 6 easy steps
How to create a local Android open source project mirror in 6 easy steps
 
DevNet Associate : Python introduction
DevNet Associate : Python introductionDevNet Associate : Python introduction
DevNet Associate : Python introduction
 
Integrating security testing into your container build pipeline - SDD308 - AW...
Integrating security testing into your container build pipeline - SDD308 - AW...Integrating security testing into your container build pipeline - SDD308 - AW...
Integrating security testing into your container build pipeline - SDD308 - AW...
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)Salesforce Developer eXperience (SFDX)
Salesforce Developer eXperience (SFDX)
 
Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17Excelian hyperledger walkthrough-feb17
Excelian hyperledger walkthrough-feb17
 
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMasterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM Roles
 
Jbossworld Presentation
Jbossworld PresentationJbossworld Presentation
Jbossworld Presentation
 
Bugzilla Installation Process
Bugzilla Installation ProcessBugzilla Installation Process
Bugzilla Installation Process
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 

Recently uploaded

Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
Severalnines
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
anfaltahir1010
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 

Recently uploaded (20)

Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Kubernetes at Scale: Going Multi-Cluster with Istio
Kubernetes at Scale:  Going Multi-Cluster  with IstioKubernetes at Scale:  Going Multi-Cluster  with Istio
Kubernetes at Scale: Going Multi-Cluster with Istio
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLESINTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
INTRODUCTION TO AI CLASSICAL THEORY TARGETED EXAMPLES
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 

CICD With GitHub, Travis, SonarCloud and Docker Hub

  • 1. CI/CD with GitHub, Travis CI, SonarCloud and Docker Hub How to include CICD into your GitHub project This work is licensed under the Creative Commons Attribution Non Commercial Share Alike 3.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
  • 3. Requisites GITHUB  Docker Hub account TRAVIS  Access to Travis with your GitHub account DOCKER  GitHub account CODECOV  Access to CodeCov with your GitHub account (optional) SONARCLOUD  Access to SonarCloud with your GitHub account
  • 4. Requisites IDE FORMATTER  Use a formatter in your IDE.  This is an example for Eclipse. Import in the Java Preferences  To apply Ctrl+A and Ctrl+Shift+F. To disable the formatting: // @formatter:off // @formatter:on
  • 5. Requisites IDE XML INDENTANTION  Use XML indentation in your IDE.  XML indentation of 4 spaces. XML Preferences. XML Editor
  • 6. Steps FROM THE BEGINNING  Fork spring-boot-template repository  Carefully read the README file and the slides  Check all the files to be changed mentioned in the Initial Configuration and use the same value to replace the same strings  Use a useful formatter and XML indentation 4.
  • 8. Variablesto configure GITHUB  Modify the repo badges and description in README  Create a new branch “release” starting from “master”  Modify DISCLAIMER and LICENSE-AGREEMENT (EULA) (Substitute **Spring Template** string by your project). Check the license and terms TRAVIS  Modify the GitHub repo in .travis/prepare.sh script. Find and replace spring-boot-template string  Have a look at .travis/push.sh and settings.xml to know the environment variables used
  • 9. Variablesto configure POM (BEFORE IMPORTING IN THE IDE)  Find and replace spring-boot-template string  SCM section. Include the proper GitHub repo  ArtifactId and version (if applicable)  Name, description and final name CHANGELOG  Add the proper title and description of the repo CHANGELOG.md and changelog.mustache  Modify the GitHub Api in changelog.json file. Find and replace spring-boot-template string DOCKER  Find and replace spring-boot-template string
  • 11. GitHub Configuration  Create a Personal Access Token
  • 12. GitHub Configuration  Protect ‘master’ and ‘release’ branches
  • 13. GitHub MasterConfiguration  Configure ‘master’ branch to check Travis before merging
  • 14. GitHub MasterConfiguration  Configure ‘master’ branch to check Travis before merging
  • 17. TravisCI Whatis  Travis CI is an automation server freely available for open source projects with a couple of clicks and small file configuration (.travis.yml).
  • 18. TravisCI .travis.yml  Travis CI runs the CI (clean, test, package and sonar goals) when we merge features into master and runs the CD (release) when push to release.  A complete .travis.yml example is here: language: java sudo: false # faster builds cache: directories: - $HOME/.m2 env: global: - secure: “ addons: sonarcloud: organization: "arihealth“ token: secure: xxxx= script: - if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then mvn clean test; mvn package - Dmaven.test.skip=true; mvn sonar:sonar; fi - if [ "$TRAVIS_BRANCH" = "master" ]; then mvn clean test; mvn sonar:sonar; fi - if [ "$TRAVIS_BRANCH" = "release" ]; then chmod +x .travis/prepare.sh && .travis/prepare.sh; mvn -s .travis/settings.xml -B release:clean release:prepare; git push --tags; mvn -s .travis/settings.xml -B release:perform; chmod +x .travis/push.sh && .travis/push.sh; fi
  • 19. TravisCI EnablingCI  Access https://travis-ci.org with your GitHub account  Browse the public Projects  Enable the GitHub repository (it should contain the .travis.yml file)
  • 20. TravisCI Configuringthehooks  Travis must be executed in PRs and Push actions. Enable both options  The script ignores branches distinct from master and release
  • 21. TravisCI Environmentvariables  Travis CI has an elegant way to configure secrets using environment variable  Add the environment variables. They are used inside the maven settings.xml and prepare.sh included in folder .travis. Have a look at them.
  • 22. TravisCI Encryptingvariables  With Travis CI we can encrypt the environment variables  Please note that encrypted environment variables are not available for pull requests from forks.  The encrypted values can be added by anyone, but are only readable by Travis CI  This way we can reuse them inside the .travis.yml file  For Windows Ruby gem can be downloaded from rubyinstaller  To include encrypted variables into .travis.yml  gem install travis  travis encrypt SOMEVAR=“secretvalue” –add  Further information here  Remember that encryption is done at repository level, so you need to encrypt again your variables
  • 24. CodeCov  Open source code test coverage  Access https://codecov.io/ using your GitHub credentials  No need to enable the GitHub repo as Travis CI, but Jacoco (or similar enabled)  Add the following snippet to your .travis.yml after_success: - bash <(curl -s https://codecov.io/bash)
  • 26. SonarCloud Configuration  Follow using SonarCloud with Travis CI guidelines 1. Create a user authenticated token for your account in SonarCloud with your GitHub account 2. Encrypt this token travis encrypt abcdef0123456789 or define SONAR_TOKEN in your Repository Settings.
  • 27. SonarCloud EnableGitHubrepos 3. Find which SonarCloud.io organization you want to push your project on and get its key
  • 28. SonarCloud EnableGitHubrepos 3. Find which SonarCloud.io organization you want to push your project on and get its key and add the project.
  • 29. SonarCloud EnableGitHubrepos 3. Find which SonarCloud.io organization you want to push your project on and get its key
  • 30. SonarCloud EnableGitHubrepos 4. Add this snippet to your .travis.yml file: addons: sonarcloud: organization: "arihealth" token: secure: “***********”  script:  - if [ "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = true ]; then mvn clean  test; mvn package -Dmaven.test.skip=true; mvn sonar:sonar –Dsonar.projectKey=arihealth_spring-boot-template;
  • 32. DockerHub Whatis  Open source repository of Docker images  You need an account at https://hub.docker.com/  You can create an organization for your Lab or department  Allow access permission in your GitHub account
  • 33. DockerHub Configuration  Link your GitHub account to Docker at My Profile/Edit profile, this is needed for the Automatic builds
  • 34. DockerHub GitHub–AuthorizedOauthApps  Check the Authorized OAuth Docker Hub Builder Application in GitHub
  • 35. DockerHub Createanewrepository  Click “Repositories” and “Create Repository +”  Select the GitHub account Connected and the user and repo to link (in case you have organizations)  Then “Click here to customize the build settings” for the Automatic Builds
  • 36.  In “Build Rules”  Generate a Docker Tag “{sourceref}” version from Source Type “Tag” and the Source is “/^[0-9.]+$/” (any semver version). Which means when a new tag is generated in GitHub (during the Continuous Delivery workflow)  Generate a Docker Tag “latest” version from Source Type “Branch” and Source “release”  Release branch receives pushes only when a new version is generated DockerHub Createanewrepository
  • 37.  Automatic Builds can be modified in the “Builds” section of the image “Configure Automatic Builds” button DockerHub Builds
  • 38. Material  https://github.com/AriHealth/spring-boot-template  https://dzone.com/articles/applying-cicd-to-java-apps- using-spring-boot  https://docs.travis-ci.com/user/languages/java/  https://coderwall.com/p/9b_lfq/deploying-maven-artifacts- from-travis  https://github.blog/2013-05-16-personal-api-tokens/  https://github.com/settings/tokens/  https://docs.travis-ci.com/user/sonarcloud/  https://stackoverflow.com/questions/58821867/how-to- share-credentials-used-in-travis-ci  https://docs.travis-ci.com/user/environment-variables/  https://docs.travis-ci.com/user/encryption-keys/#usage
  • 39. Thanks! For more information please contact: carlos.cavero@atos.net