1.EC2 구축 [Jenkins/Web]
2.Git Hub 생성
3.S3 생성
4.Jenkins 구축
5.CodeDeploy 구축
6.Git,Jenkins,CodeDeploy 연동
----------------------------------------------------------------------------------------
■EC2에 AmazonLinux 설치 후 Jenkins 설치
(설치 시 버전 확인 후 설치 할 것)
sudo yum update
sudo yum install -y java-1.8.0-openjdk-devel.x86_64
sudo /usr/sbin/alternatives --config java
■jenkins 설치된 ec2에 aws-cli 설치
sudo yum install -y aws-cli
cd /home/ec2-user/
sudo aws configure
[
-Access Key
CodeDeploy 용 IAM 의 AC Key 등록
-Secret Access Key
CodeDeploy 용 IAM 의 SC Key 등록
-region name
ap-northeast-2
사용 리전
-output format
json
]
■CodeDeploy Agent 설치
wget https://aws-codedeploy-ap-northeast-2.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
sudo service codedeploy-agent status
(실행 확인)
■EC2 재 부팅 시 자동으로 Deploy Agent 실행 되도록 sh 생성
sudo vim /etc/init.d/codedeploy-startup.sh
v 내용
#!/bin/bash
echo 'Starting codedeploy-agent'
sudo service codedeploy-agent restart
sudo chmod +x /etc/init.d/codedeploy-startup.sh
---------------------------------------------------------------------------------
■배포 시 사용 될 yml과 sh 생성
배포 받을 EC2 Web 2대 생성 (ALB로 생성)
■CodeDeploy 생성
IAM 역할 생성
■CD 수동 테스트
(*수동 배포 테스트 시 해당 EC2에 S3 또는 GitHub 올라간 자료가 들어오면 정상*)
■Jenkins 플러그인 설치
■Jenkins Project 생성
GitHub WebHook 적용
해당 프로젝트-Settings
GitHub에 자료가 추가/수정 될 시 자동으로 Jenkins에서 합쳐서 S3로 올린다음 S3 내용을 EC2로 배포 함
'Jenkins' 카테고리의 다른 글
[Jenkins]pipeline sh 기본 서식 (0) | 2022.06.15 |
---|---|
[Jenkins] Node 추가 (Slave Agent 설치) (0) | 2022.06.08 |
[Jenkins]Webhook 설정 (0) | 2022.04.20 |
[Jenkins] GitLab 연동 및 테스트 (0) | 2022.04.20 |
[Jenkins] EC2 Tomcat 배포 설정 (0) | 2022.03.17 |