====== Jenkins Agent ( slave ) ====== * see [[ci:jenkins:slave|Jenkins Slave]] * [[https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds|Jenkins : Distributed builds]] ===== 제한 사항 ===== * agent 의 executor 는 CPU 갯수를 넘기지 말도록 하고 더 적게한다. ===== agent 기본 사항 ===== * [[https://www.youtube.com/watch?v=e2RkeISsDVE&t=1s|Jenkins Master and Slave Configuration | Jenkins Distributed Architecture Tutorial]] : 동일 machine 에서 ''agent.jar''로 직접 만드는 slave agent. ===== docker-pipeline ===== * [[https://www.jenkins.io/doc/book/pipeline/docker/|Using Docker with Pipeline]] : 원하는 [[:docker|Docker]] 이미지를 자유롭게 파이프라인의 agent 로 사용. * pipeline 의 특정 stage에만 적용하는 것도 가능하고, ''Dockerfile''을 직접 빌드할 수도 있음. * [[https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow|Docker Pipeline plugin]] * [[https://www.youtube.com/watch?v=ymI02j-hqpU|How to Setup Docker Containers As Build Agents for Jenkins - YouTube]] ===== docker images ===== * [[aws:fargate|AWS Fargate]]를 이용하면, [[:docker|Docker]] 컨테이너를 필요에 따라 수행하는 Jenkins Agent 로 만들 수 있다. * [[ci:jenkins:aws_plugin|Jenkins AWS Plugins]] * [[https://hub.docker.com/r/jenkins/agent/|jenkins/agent]] : 다른 agent 들의 부모. debian, alpine, windows 선택가능. * [[https://github.com/jenkinsci/docker-agent|jenkinsci/docker-agent: Base Docker image for Jenkins Agents]] * username : ''jenkins'' * [[https://hub.docker.com/r/jenkins/inbound-agent/|Docker jenkins/inbound-agent]] : java 버전별로 찾을 수 있다. docker & fargate 용. * [[https://github.com/jenkinsci/docker-inbound-agent|jenkinsci/docker-inbound-agent: Docker image for a Jenkins agent which can connect to Jenkins using TCP or Websocket protocols]] * [[https://hub.docker.com/r/jenkins/ssh-agent|jenkins/ssh-agent - Docker Image | Docker Hub]] * [[https://hub.docker.com/r/jenkins/agent|jenkins/agent - Docker Image | Docker Hub]] ===== kubernetes / k8s ===== * [[:kubernetes|Kubernetes k8s]] * [[https://www.youtube.com/watch?v=ZXaorni-icg|How to Use Kubernetes Pods As Jenkins Agents - YouTube]] ===== Windows ===== * on [[:windows|Windows]] * [[https://www.youtube.com/watch?v=N8AQTlHoBKc|How to Install Jenkins Agent on Windows - YouTube]] ===== stash / unstash ===== * [[https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/|Pipeline: Basic Steps]] ''stash'' * [[https://www.youtube.com/watch?v=0GQZzLlnUws|What Is stash and unstash in Jenkins? - YouTube]] * 특정 agent 에서 ''stash'' 한 것을 다른 agent 에서 ''unstash'' 하여 여러 agent 들 간에 build 도중 생성된 파일을 공유할 수 있다. * [[https://gist.github.com/darinpope/74462757661613ac9b8cdd742c3918a2|What-Is-stash-and-unstash-in-Jenkins.md]] pipeline { agent none stages { stage('Hello') { agent { label 'linux' } steps { sh ''' touch file.txt mkdir -p target touch target/file2.jar touch target/file3.war tree ''' stash(name: 'myStash', includes: '**/*.war') } } stage('check the file') { agent { label 'macos' } steps { unstash 'myStash' sh 'tree' } } } } ===== 참조 ===== * [[https://www.youtube.com/watch?v=99DddJiH7lM|How to Create an Agent Node in Jenkins - YouTube]] * [[https://youtu.be/MTLgbp0GH8w|How to restart jenkins agent]] : UI, Script 등으로 재시작하기