Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

CICD 맛보기

1.015 visualizaciones

Publicado el

github, travis, heroku 를 활용한 ci/cd 맛보기

Publicado en: Software
  • Sé el primero en comentar

CICD 맛보기

  1. 1. CI/CD 맛보기 SDS ACT 김기훈 (koreakihoon@gmail.com)
  2. 2. 지속적 통합(Continuous Integration) 지속적 통합은 자동화된 빌드 및 테스트가 수행된 후, 개발자가 코드 변경 사항을 중앙 리포지토리에 정기적으로 병합하는 데브옵스 소프트웨어 개발 방식입니다. 지속적 통합은 소프트웨어 릴리스 프로세스 중 빌드 또는 통합 단계를 주로 가리키며, 자동화 구성 요소(예: CI 또는 빌드 서비스)와 문화적 구성 요소(예: 빈번하게 통합하도록 학습) 모두를 포함합니다. 지속적 통합의 핵심 목표는 버그를 신속하게 찾아 해결하고, 소프트웨어 품질을 개선하고, 새로운 소프트웨어 업데이트를 검증 및 릴리스하는 데 걸리는 시간을 단축하는 것입니다. https://aws.amazon.com/ko/devops/continuous-integration/
  3. 3. 소스 형상관리(버전관리) https://ko.wikipedia.org/wiki/버전_관리
  4. 4. CI(continuous integration) 툴 https://code-maze.com/top-8-continuous-integration-t ools/
  5. 5. 배포 환경
  6. 6. https://www.enterpriseirregulars.com/116202/race-pipeline-atlassian-aint-playin-introducing-devops-marketplace/
  7. 7. 오늘의 목표
  8. 8. Git & GitHub
  9. 9. Git 설치 https://git-scm.com/downloads
  10. 10. Git 간편 안내서 http://git.huit.harvard.edu/guide/index.ko.html
  11. 11. Git command https://try.github.io https://learngitbranching.js.org/
  12. 12. Github 가입 https://github.com/
  13. 13. organization & repository 만들기 github 에 원격 저장소 만들기
  14. 14. 소스코드 준비 http://start.spring.io/ - generate project - workspace에 압축 풀기 - $ ./gradlew clean build - $ ./gradlew bootRun
  15. 15. Import gradle project
  16. 16. application.yml spring: application: name: student-service datasource: initialize: false sql-script-encoding: UTF-8 driverClassName: org.h2.Driver url: jdbc:h2:mem:func_testdb;MODE=MYSQL;DB_CLOSE_ON_EXIT=FALSE username: ${DB_USERNAME:sa} password: ${DB_PASSWORD:} jpa: hibernate: #none, validate, update, create-drop, create ddlAuto: update show-sql: true
  17. 17. Controller @RestController @RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public class StudentController { private final StudentRepository studentRepository; @Autowired public StudentController(StudentRepository studentRepository) { this.studentRepository = studentRepository; } @GetMapping("/students") public List<Student> getStudents() { return (List<Student>) studentRepository.findAll(); } @PostMapping("/students") public Student createStudent(@RequestBody Student student) { return studentRepository.save(student); } }
  18. 18. Repository & Entity import org.springframework.data.jpa.repository.JpaRepository; public interface StudentRepository extends JpaRepository<Student, Long>{ } @Entity public class Student { @Id @GeneratedValue private Long id; private String name; public Long getId() { return id; } public String getName() { return name; } }
  19. 19. Controller test @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class StudentControllerTest { @MockBean(name = "studentRepository") private StudentRepository mockStudentRepository; @Autowired private TestRestTemplate restTemplate; @Test public void getStudents() { ParameterizedTypeReference<List<Student>> type = new ParameterizedTypeReference<List<Student>>() {}; restTemplate.exchange("/students", HttpMethod.GET, new HttpEntity<>(null, null), type); verify(mockStudentRepository).findAll(); } @Test public void createStudent() { Student student = new Student(); restTemplate.postForEntity("/students", student, Student.class); verify(mockStudentRepository).save(eq(student)); } }
  20. 20. config CORS @Configuration @EnableWebMvc public class WebConfig extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowCredentials(false) .maxAge(3600); } }
  21. 21. cors test fetch("http://localhost:8080/students").then(resp => { console.log(resp) })
  22. 22. git init git add . git commit -m “init project” git remote add origin https://github.com/kihoonkim/scsa_ci.git git push -u origin master
  23. 23. travis
  24. 24. Travis CI 가입 https://travis-ci.org/
  25. 25. enable repository
  26. 26. settings
  27. 27. .travis.yml 설정 https://docs.travis-ci.com/user/languages/java/ .travis.yml 생성 $ git add . $ git commit -m “add .travis.yml” $ git push
  28. 28. travis cli ruby gem 설치 - https://rubygems.org/ - windows: https://rubyinstaller.org/ $ gem install travis > gem certificate verify failed 오류시 $ gem sources --remove https://rubygems.org/ $ gem sources -a http://rubygems.org/ > gem via proxy $ gem install --http-proxy http://proxy.server:8080 travis
  29. 29. dashboard
  30. 30. Travis dashboard https://travis-ci.org/dashboard
  31. 31. CCMenu http://ccmenu.org/ - Mac : ccmenu - Windows: CCTray - Linux: BuildNotify https://sourceforge.net/projects/ccnet/files/CruiseControl.NET%20Releases/
  32. 32. CCTray with Travis https://docs.travis-ci.com/user/cc-menu/ CC Feed : https://api.travis-ci.org/repos/<owner>/<repository>/cc.xml
  33. 33. More tools... Apps, Clients and Tools: https://docs.travis-ci.com/user/apps/
  34. 34. Notification
  35. 35. slack 가입 https://slack.com/
  36. 36. slack travis app 설정
  37. 37. slack notifications 설정 https://docs.travis-ci.com/user/notifications/#Configuring-Slack-notifications .travis.yml $ travis encrypt "scsaci:MmCO8MbgVKJ5pkB0Ol7Szcoe" --add notifications.slack.rooms
  38. 38. Deploy
  39. 39. API key
  40. 40. https://docs.travis-ci.com/user/deployment/heroku/ $ travis encrypt “your_api_key” --add deploy.api_key .travis.yml
  41. 41. deploy 확인
  42. 42. Configure Add-ons
  43. 43. Billing Information
  44. 44. click
  45. 45. HeidiSQL max_user_connections 오류시 설정 추가 # application.yml spring: datasource: tomcat: max-active: 5
  46. 46. https://github.com/kihoonkim/scsa_ci
  47. 47. 끝.

×