본문 바로가기

etc

[DevSecOps 파이프라인] Jenkins 설치 (GCP instance 위에)

GCP instance 구성

  • Seoul region
  • Centos7

 

$ sudo su -
$ yum install wget

Jenkins 설치

$ wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
$ rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
$ rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key**
$ yum install jenkins
$ vi /etc/sysconfig/jenkins
.... JENKINS_PORT=”9090” ....

$ firewall-cmd --permanent --add-port=9090/tcp
$ systemctl start jenkins

 

*** 만약 다음과 같은 에러가 난다면 openjdk를 설치해줘야 한다.

$ systemctl start jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.
$ systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2020-09-30 06:08:01 UTC; 8s ago Docs: man:systemd-sysv-generator(8) Process: 1605 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE) Sep 30 06:08:01 jenkins systemd[1]: Starting LSB: Jenkins Automation Server... Sep 30 06:08:01 jenkins runuser[1610]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Sep 30 06:08:01 jenkins jenkins[1605]: Starting Jenkins bash: /usr/bin/java: No such file or directory Sep 30 06:08:01 jenkins runuser[1610]: pam_unix(runuser:session): session closed for user jenkins Sep 30 06:08:01 jenkins jenkins[1605]: [FAILED] Sep 30 06:08:01 jenkins systemd[1]: jenkins.service: control process exited, code=exited status=1 Sep 30 06:08:01 jenkins systemd[1]: Failed to start LSB: Jenkins Automation Server. Sep 30 06:08:01 jenkins systemd[1]: Unit jenkins.service entered failed state. Sep 30 06:08:01 jenkins systemd[1]: jenkins.service failed. **$ yum list java*jdk-devel** Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.kakao.com * epel: d2lzkl7pfhq30w.cloudfront.net * extras: mirror.kakao.com * updates: mirror.kakao.com Available Packages java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base java-1.7.0-openjdk-devel.x86_64 1:1.7.0.261-2.6.22.2.el7_8 updates java-1.8.0-openjdk-devel.i686 1:1.8.0.262.b10-0.el7_8 updates java-1.8.0-openjdk-devel.x86_64 1:1.8.0.262.b10-0.el7_8 updates java-11-openjdk-devel.i686 1:11.0.8.10-0.el7_8 updates java-11-openjdk-devel.x86_64 1:11.0.8.10-0.el7_8 updates java-latest-openjdk-devel.x86_64 1:14.0.2.12-1.rolling.el7 epel **$ yum install java-1.8.0-openjdk-devel.x86_64** $ **systemctl start jenkins** $ **systemctl status jenkins** ● jenkins.service - LSB: Jenkins Automation Server Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) Active: active (running) since Wed 2020-09-30 06:12:32 UTC; 23s ago Docs: man:systemd-sysv-generator(8) CGroup: /system.slice/jenkins.service └─1808 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/... Sep 30 06:12:32 jenkins systemd[1]: Starting LSB: Jenkins Automation Server... Sep 30 06:12:32 jenkins runuser[1792]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) Sep 30 06:12:32 jenkins jenkins[1787]: Starting Jenkins [ OK ] Sep 30 06:12:32 jenkins systemd[1]: Started LSB: Jenkins Automation Server.

 

방화벽 규칙 생성

  • 대상: 네트워크의 모든 인스턴스
  • 소스 IP 범위: 0.0.0.0/0
  • tcp: 9090

 

그리고 http://<외부IP>:9090 에 접속