본문 바로가기

DevOps/Jenkins

[Jenkins] Job DSL로 Pipeline 프로젝트 생성

TODO

https://juyeonee826.tistory.com/180

 

NodeJS 애플리케이션 Docker 배포하는 Jenkins Pipeline 생성

* 아래 강의 학습 중📚 Udemy - DevOps 학습: 파이프라인 및 Docker를 이용한 Jenkins 와의 CI/CD 환경 jenkins 2.401.3 TODO https://juyeonee826.tistory.com/177 Jenkins로 NodeJs 애플리케이션 Docker 배포 * 아래 강의 학습 중

juyeonee826.tistory.com

여기서 UI로 생성하는 Pipeline Project를 Job DSL로 생성해보려고 한다.

 

 

job dsl 코드 작성

docker_demo_pipeline.groovy

pipelineJob('nodejs pipeline dsl') {
  definition {
    cpsScm {
      scm {
        git {
          remote {
            url('https://github.com/%%%%%/docker-demo.git')
          }
          branch('*/master')
          scriptPath('misc/Jenkinsfile')
        }
      }
      lightweight()
    }
  }
}

 

 

시드 프로젝트 생성

job dsl로 작성한 pipeline 프로젝트를 생성해줄 기반이 될 seed 프로젝트 생성하기

 

 

script names may only contain letters, digits and underscores, but may not start with a digit

빌드 했더니 숫자, 문자, _ 이렇게만 가능하다구 한다.

 

 

script approve

스크립드 승인까지 하면 완료.

 

+

seed project 삭제해도 child project 삭제 안 된다!

 

 

참고

https://plugins.jenkins.io/job-dsl/

 

Job DSL

This plugin allows Jobs and Views to be defined via DSLs

plugins.jenkins.io

https://stackoverflow.com/questions/43999508/jenkins-job-dsl-how-to-read-pipeline-dsl-script-from-file

 

Jenkins Job DSL: How to read Pipeline DSL script from file?

I want to generate my pipeline plugin based jobs via Job DSL, which is contained in a git repository that is checked out by Jenkins. However, I think it is not very nice to have the pipeline scri...

stackoverflow.com