Back End/CI&CD

[CI/CD] Travis CI Job LifeCycle 공식문서와 after_script에 대하여

DevPing9_ 2022. 2. 26. 01:11

The Build #

The .travis.yml file describes the build process. A build in Travis CI is a sequence of stages. Each stage consists of jobs run in parallel.

 

.travis.yml 파일은 빌드 프로세스를 조정하는 파일이다.
트래비스 CI에서 빌드는 stage의 묶음이며, 각 stage는 병렬적으로 실행되는 job들로 이루어져있다.
(각 stage가 개별 VM 환경에서 돌아간다는 뜻)

개별 VM에서 병렬적으로 돌아가지 않고, 순차적으로 돌리는 방법도 있긴 하다.

 

 

The Job Lifecycle #

Each job is a sequence of phases. The main phases are:

  1. install - install any dependencies required
  2. script - run the build script
각각의 job은 phase들로 이루어져 있는데,
그 중에 메인이라고 칭할 수 있는 것은 install과 script 이다. 

트래비스 CI 의 생애주기는 아래와 같다.

 

Travis CI can run custom commands in the phases:

  1. before_install - before the install phase
  2. before_script - before the script phase
  3. after_script - after the script phase.

 

after_script 가 초기버전과 달라졌는데, https://blog.travis-ci.com/after_script_behavior_changes 에서 확인 할 수 있다. 

초기 버전에는 테스트 실패시 무시되는 옵션이 었는데, 이제는 테스트결과와 상관없이 작동한다.

 즉, after_success 와 after_failure 뒤쪽에 위치한다.

 

  1. after_success - when the build succeeds (e.g. building documentation), the result is in TRAVIS_TEST_RESULT environment variable
  2. after_failure - when the build fails (e.g. uploading log files), the result is in TRAVIS_TEST_RESULT environment variable

 

아래는 생애주기 순서이다.

 

There are three optional deployment phases.

The complete sequence of phases of a job is the lifecycle. The steps are:

  1. OPTIONAL Install apt addons
  2. OPTIONAL Install cache components
  3. before_install
  4. install
  5. before_script
  6. script
  7. OPTIONAL before_cache (if and only if caching is effective)
  8. after_success or after_failure
  9. OPTIONAL before_deploy (if and only if deployment is active)
  10. OPTIONAL deploy
  11. OPTIONAL after_deploy (if and only if deployment is active)
  12. after_script

 

after_script가 deploy 보다도 뒤에 실행된다는 점에 주의하자. (피봤다..)
728x90