본문 바로가기
DevOps/Jenkins

Jenkins pipeline - Sphinx publish(HTML)

by 돈코츠라멘 2020. 2. 12.

Settings

(1) 아래 두 가지의 Plugin을 모두 설치해야 함

  • ShiningPanda - Python 설치, Path 지정
  • Pyenv Pipeline - Python virtualenv

(2) Jenkins 관리> Global Tool Configuration 설정

jenkins 공식 이미지에는 python2만 깔려있음 - python3을 사용하거나 여러 버전의 python으로 테스트하기 위해서는 따로 설치를 하고 위의 설정에서 추가해야 함

jenkins:
  image: 'jenkins/jenkins:latest'
  restart: always
  user: root
  privileged: true
  environment:
    - JAVA_ARGS=-Dorg.apache.commons.jelly.tags.fmt.timeZone=Asia/Seoul
  ports:
    - '8080:8080'
    - '50000:50000'
  volumes:
    - '/home/gitlab/jenkins_data:/var/jenkins_home'
    - '/home/user/anaconda3:/var/anaconda3' # !!!!! 추가

Docker로 Jenkins를 올린경우 위와 같이 로컬에 설치된 anaconda를 mount 해서 바로 사용

pipeline

stage('Publish HTML') {

    def htmlDocDir = deployDir + '/doc/html'

    withPythonEnv('anaconda3') {
        sh 'pip install sphinx sphinx_rtd_theme'
        sh 'cd doc && make html'
    }
    sh '''#!/bin/bash
        htmlDocDir="''' + htmlDocDir + '''"
        if [ -d ${htmlDocDir} ]; then
            rm -rf ${htmlDocDir}
        fi
        mkdir -p ${htmlDocDir}
        mv -f doc/build/html/* ${htmlDocDir}
    '''
}

 

(참고1) 만약 make 명령어를 못 찾아서 아래와 같은 에러가 발생한다면?

+ cd doc
+ make html
/var/jenkins_home/workspace/kronos-master-CI@tmp/durable-1051d6aa/script.sh: 1: /var/jenkins_home/workspace/kronos-master-CI@tmp/durable-1051d6aa/script.sh: make: not found

What you can do is run a docker exec against that container with the user of root, and install all the deps with apt-get and then your build will run.

서버에서는 바로 apt 명령으로, Docker로 Jenkins를 올린 경우는 image에 bash로 들어가서 아래 apt 명령 실행 후 다시 Build

$ apt-get update 
$ apt-get install build-essential

 

(참고2) 유용한 Jenkins Plugin - HTML Publisher

'DevOps > Jenkins' 카테고리의 다른 글

Jenkins pipeline - npm build  (0) 2020.02.12

댓글