본문 바로가기

IT/DevOps

[Jenkins] Docker Agent Container 연결

728x90

Docker 호스트

 

개인키 생성

$ ssh-keygen -f ~/.ssh/jenkins_agent_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/jbuilds/.ssh/jenkins_agent_key.
Your public key has been saved in /home/jbuilds/.ssh/jenkins_agent_key.pub.
The key fingerprint is:
SHA256:xFI/qPSfkjVtL2GrkFUmXYu46RLivsOk4LKTcgcGqsA root@jbuildsx
The key's randomart image is:
+---[RSA 2048]----+
|        .     .  |
|       o o o o . |
|      o + = = .  |
|.    . =   O     |
|o.    o S * =    |
|oE+  ... O = +   |
|o+ o +. * + o .  |
|* o o.o  + . .   |
|o= .  oo  .      |
+----[SHA256]-----+

 

개인키 확인

$ cd ~/.ssh 
$ cat jenkins_agent_key
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyXeYkA4w7LYr+FTyCjkh7TdTHlP36SMO7N7I5Tb8fPdgPIlK
RQQ5iBUJ4FlEGhqG3oO2e4xeZWaFkO0BLLKt3EsyEnoIk+GkBEKkBh82QvFmBGk6
tYZJj5Is+3/y0fvk4NhDgOZz5pB8932g1aXFPHcYw/zYsGnqaI6Nlc+JGH+yijwo
...
...
dkYZ9BkCgYBAqxSe5iIhlqgcmcr1IKHTW4Mh6SmIx4nmkJhyYS0tQRp2UWqVJPgY
+/9o85fScrn4tZIL8CguxHyK/NQ0O99uBEKXTGpz3yN5M5pUeeEM31M8TPM+CBLt
WDEtHU6eJmmMy/t6W2QyvlYn0XLaVCtKRq2cERAeEFmiao4jZ9LM2g==
-----END RSA PRIVATE KEY-----

 

공개키 확인

$ cat jenkins_agent_key.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJd5iQDjDstiv4VPIKOSHtN1MeU/fpIw7s3sjlNvx892A8iUpFBDmIFQngWUQaGobeg7Z7jF5lZoWQ7QEssq3

 

Jenkins 설정

Manage Credentials 이동

Global > Add Credentials > SSH Username with private key

ID jenkins
Private Key -----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyXeYkA4w7LYr+FTyCjkh7TdTHlP36SMO7N7I5Tb8fPdgPIlK
RQQ5iBUJ4FlEGhqG3oO2e4xeZWaFkO0BLLKt3EsyEnoIk+GkBEKkBh82QvFmBGk6
tYZJj5Is+3/y0fvk4NhDgOZz5pB8932g1aXFPHcYw/zYsGnqaI6Nlc+JGH+yijwo
...
...
dkYZ9BkCgYBAqxSe5iIhlqgcmcr1IKHTW4Mh6SmIx4nmkJhyYS0tQRp2UWqVJPgY
+/9o85fScrn4tZIL8CguxHyK/NQ0O99uBEKXTGpz3yN5M5pUeeEM31M8TPM+CBLt
WDEtHU6eJmmMy/t6W2QyvlYn0XLaVCtKRq2cERAeEFmiao4jZ9LM2g==
-----END RSA PRIVATE KEY-----

 

 

Docker Agent Templates

Connect method Connect with SSH
SSH Key Use configured SSH credentials
SSH Credentials Jenkins
Host key Verification Strategy Non verifying Verification Strategy

 

Container Settings

Environment JENKINS_AGENT_SSH_PUBKEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJd5iQDjDstiv4VPIKOSH.......

 

Advanced

JavaPath /usr/local/openjdk-8/bin/java
728x90

태그

Comments