jenkins
  • groovy
  • comments
  • jenkins-pipeline
  • 2017-02-18 1 views 23 likes 
    23

    젠킨스 파일에 주석이 있습니까? 그렇다면 구문은 무엇입니까?Jenkinsfile에 주석을 추가 할 수 있습니까?

    저는 선언적 파이프 라인 구문을 사용하고 있습니다.

    내 SMTP 서버가 작동 할 때까지 아래 "게시물"섹션을 주석으로 작성하고 싶습니다.

    pipeline { 
    
        agent { label 'docker-build-slave' } 
    
        environment { 
        IMAGE = 'registry.gitlab.com/XXXXX/bible-server' 
        DOCKER_REGISTRY_CREDENTIALS = credentials('DOCKER_REGISTRY_CREDENTIALS') 
        } 
    
        options { 
        timeout(10) 
        } 
    
        stages { 
    
        stage('Test') { 
         steps { 
         sh 'yarn' 
         sh 'npm test' 
         } 
        } 
    
        stage('Build') { 
         when { 
         branch '*/master' 
         } 
         steps { 
         sh 'docker login -u ${DOCKER_REGISTRY_CREDENTIALS_USR} -p ${DOCKER_REGISTRY_CREDENTIALS_PSW} registry.gitlab.com' 
         sh 'docker build -t ${IMAGE}:${BRANCH_NAME} .' 
         sh 'docker push ${IMAGE}:${BRANCH_NAME}' 
         } 
        } 
    
        stage('Deploy') { 
         when { 
         branch '*/master' 
         } 
         steps { 
         echo 'Deploying ..' 
         } 
        } 
        } 
    
        post { 
        success { 
         mail to: "[email protected]", subject:"SUCCESS: ${currentBuild.fullDisplayName}", body: "Yay, we passed." 
        } 
        failure { 
         mail to: "[email protected]", subject:"FAILURE: ${currentBuild.fullDisplayName}", body: "Boo, we failed." 
        } 
        } 
    } 
    

    답변

    52

    Jenkinsfile는 의견의 자바 (그리고 C) 형태로 사용 그루비로 작성 :

    /* this 
        is a 
        multi-line comment */ 
    
    // this is a single line comment 
    
    +0

    내가 쉬 섹션의 내부 jenkinsfile에 선언 파이프 라인을 사용하고 및 그것은 아마 그것을 실패 블록 수준에서 작동합니다. '파이프 라인 { ... 스테이지 ('태그 설정') { steps { sh ''012 ' $ {params_file} /* echo "env.docker_ws = '/ usr/local/lib/node_modules/$ {repo}'">> $ {params_file} $ {m_time} _ $ {BUILD_NUMBER} } */ '' '<' 오류/bash 권한 오류가 발생했습니다. – Chen

    +3

    'sh' 섹션 안에 쉘 주석 문자'# '를 사용해야합니다. – BMitch

    관련 문제