相关疑难解决方法(0)

詹金斯管道如果不工作

我正在创建一个示例jenkins管道,这里是代码.

pipeline {
    agent any 

    stages {    
        stage('test') { 
            steps { 
                sh 'echo hello'
            }            
        }
        stage('test1') { 
            steps { 
                sh 'echo $TEST'
            }            
        }
        stage('test3') {
            if (env.BRANCH_NAME == 'master') {
                echo 'I only execute on the master branch'
            } else {
                echo 'I execute elsewhere'
            }                        
        }        
    }
}
Run Code Online (Sandbox Code Playgroud)

此管道失败,并显示以下错误日志

Started by user admin
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 15: Not a valid stage section definition: "if (env.BRANCH_NAME == 'master') {
                echo 'I only execute on the master branch' …
Run Code Online (Sandbox Code Playgroud)

groovy jenkins

39
推荐指数
2
解决办法
10万
查看次数

詹金斯dsl中的booleanParam

我有一个像这样的詹金斯风格的脚本:

    freeStyleJob(“test”) {
        properties { githubProjectUrl(‘…’) }
        description(‘’’job description’’’.stripMargin('|'))

        logRotator{ numToKeep(100) }

        parameters {
            stringParam(’STRINGP1’, "", “STRINGP1 description”)
            stringParam('STRINGP2’, "", “StringP2 description”)
            booleanParam(‘b1’, false)
            booleanParam(‘b2’, false)
            booleanParam(‘b3’, false)
            stringParam("EMAIL_LIST", "", "Emails")
        }

        scm {
            github(‘repo’, '${STRINGP1}', 'git', ‘giturl’)
        }

        steps {
            shell '''|#!/bin/bash
                |ARGS=""
                |fi
                |if [[ ‘${b1}’ ]]; then
                |   ARGS=$ARGS" —-p b1”
                |fi
                |if [[ ‘${b2}’ ]]; then
                |   OS_ARGS=$ARGS" —-p b2”
                |fi
                |if [[ ‘${b3}’ ]]; then
                |   ARGS=$ARGS" —-p b3”
                |fi                
                |echo ${ARGS}'''.stripMargin('|')

        }

        publishers { …
Run Code Online (Sandbox Code Playgroud)

groovy jenkins

1
推荐指数
2
解决办法
5390
查看次数

标签 统计

groovy ×2

jenkins ×2