-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration jenkins with docker #143
Comments
Installation Jenkins with DockerCreate volume directory
sudo /usr/sbin/useradd jenkins -u 1000
sudo /usr/sbin/usermod -aG docker jenkins
sudo mkdir -p /home1/irteam/jenkins_home
sudo chown -R jenkins:docker /home1/irteam/jenkins_home docker-compose 생성# docker-compose-jenkins.yml
version: '3'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
privileged: true
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- $HOME/jenkins_home:/var/jenkins_home
ports:
- 80:8080
environment:
- TZ=Asia/Seoul Create docker containerdocker-compose -f docker-compose-jenkins.yml up -d 정상적으로 jenkins가 생성되었는 지와 초기 password 확인을 위해 아래와 같이 log를 확인해본다 docker container logs jenkins Access to Jenkins web browser
초기 패스워드를 log에서 확인하지 못한 경우, 아래의 명령어를 통하여 확인할 수 있다. docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword Install suggested plugins로그인 후에 |
Update Jenkins version in Dockerdocker 환경으로 설치된 jenkins 업데이트를 위한 방법 Connect to docker containerdocker container exec -u 0 -it jenkins bash Download war file with wgetwget <jenkins war link url> Move war filemv ./jenkins.war /usr/share/jenkins
chown jenkins:jenkins /usr/share/jenkins/jenkins.war
exit Restart docker containerdocker container restart jenkins |
Add slave nodeslave node를 생성하고, master와 연결해준다. Generate ssh key of master servermaster server의 jenkins로 접속해서 ssh key를 생성한다. [irteam@ci-master ~]$ docker container exec -it jenkins /bin/bash
jenkins@f81705b28f66:/$ ssh-keygen -t rsa -C "jenkins-master"
Generating public/private rsa key pair.
Enter file in which to save the key (/var/jenkins_home/.ssh/id_rsa):
Created directory '/var/jenkins_home/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/jenkins_home/.ssh/id_rsa
Your public key has been saved in /var/jenkins_home/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:gwPOKn/0PhBQCb1jITLtXG/xae1D9VmFXVTtjsyxass jenkins-master
The key's randomart image is:
+---[RSA 3072]----+
| ..+.. +X|
|o + = . . . +|
| = +.+ o o . . + |
| oo=.o.+ o + .|
| .o+o.So o = |
| .o . .o = .|
|. .. o . . |
| o . o .o |
| .. ... .E. |
+----[SHA256]-----+ 생성한 공개키를 확인한다. jenkins@f81705b28f66:/$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC****** jenkins-master Regist ssh key of master server to slave node serverslave 노드 서버에 접속해서 앞에서 생성한 master node의 공개키를 등록한다. 만약, cd ~
mkdir .ssh
chmod 700 .ssh
cd .ssh
touch authorized_keys
chmod 644 authorized_keys master node의 공개키를 클립보드로 복사한 뒤에 아래와 같이 master node에서 slave node 서버로 ssh를 이용하여 접속이 되는 지 확인한다. jenkins@f81705b28f66:/$ ssh <username>@<slave_node server hostname>
The authenticity of host '<slave_node server hostname> (10.241.43.26)' can't be established.
ECDSA key fingerprint is SHA256:JRhdTGqvANvFIdQjVoSoBoaPf/K3lItFteFHHspIeAw.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '<slave_node server hostname>,10.241.43.26' (ECDSA) to the list of known hosts.
Last login: Thu Apr 21 18:42:23 2022 from 10.231.201.89
[<username>@<slave_node server hostname> ~]$ Create a Credential for slave nodeJenkins 관리 -> Manage Credentials에서 slave 노드의 정보를 등록해준다.
Add slave nodeJenkins 관리 -> 노드 관리 -> 신규 노드에서 slave node를 생성한다. |
Install Custom Jenkins plugins다음으로는 추가적으로 필요한 plugin 들을 설치해준다.
==== Warnings Next Generation ESLint와 같은 정적 분석 도구에 대한 리포트를 생성하기 위해 설치 docker pipeline SSH Pipeline Steps pipeline 내에서 ssh 명령어를 사용하기 위함 |
Integrate GitHub RepositoryJenkins와 GitHub 연동을 위한 과정이다. Configure OAuth with GitHub and AuthorizationInstallation
|
Installation Jdk 11
Jenkins 관리 -> Global tool configuration에서 References |
Notification빌드 결과나 특정 stage 결과에 대하여 slack, email 등과 같은 방법으로 알림을 발송하기 위한 설정이다. SlackGenerate Slack Channel Token
Configure Jenkins
Modify Jenkinsfiles for slack nofity#!/usr/bin/env groovy
void notifySlack(String message, String color) {
slackSend (channel: '<channel_name>', color: color, message: message + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
pipeline {
// ...SKIP
stages {
// ...SKIP
}
post {
success {
script {
def previousResult = currentBuild.previousBuild?.result
if (!previousResult || (previousResult && previousResult != currentBuild.result)) {
notifySlack ('SUCCESS', '#00FF00')
}
}
}
unstable {
notifySlack ('UNSTABLE', '#FFFF00')
}
failure {
notifySlack ('FAILED', '#FF0000')
}
}
} |
Server spec
Table of content
The text was updated successfully, but these errors were encountered: