Jenkinsfile管道不签出git

时间:2018-11-07 13:29:39

标签: selenium jenkins groovy jenkins-pipeline

Jenkinsfile无法提取我的硒代码来运行自动化测试,我尝试了其他方法,但仍然无法实现我所需要的。我认为行进方向错误。如果有错,请纠正我

#!groovy
pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                echo 'Checkout'
            }
        }
        stage('Build') {
            steps {
                echo 'Clean Build'
            }
        }

        stage('Deploy') {
            when { branch 'develop' }
            steps {
                echo 'Deploying'
            }
        }

        stage('Integration Test') {
            steps {
                node("Android-Build") {
                    def mvnHome = tool 'Maven'
                    stage 'Integration Test'
                    git url: 'git@bitbucket.org:automation-web.git', branch: 'feature/WebAutomation'
                    sh "${mvnHome}/bin/mvn compile"
                    stage 'Test'
                    sh "${mvnHome}/bin/mvn test"
                }
            }
        }

    }

}

1 个答案:

答案 0 :(得分:0)

尝试:

checkout([
   $class: 'GitSCM', 
   branches: [[name: 'feature/WebAutomation']], 
   doGenerateSubmoduleConfigurations: false, 
   extensions: [], 
   submoduleCfg: [], 
   userRemoteConfigs: [[
       credentialsId: 'xxx', 
       url: 'git@bitbucket.org:automation-web.git'
   ]]
])

代替:

git url: 'git@bitbucket.org:automation-web.git', branch: 'feature/WebAutomation'

解决方案2:

 stage('Integration Test') {
             steps {
                 script {
             def mvnHome = tool 'Maven'
                 checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [],submoduleCfg: [], userRemoteConfigs: [[url:'git@bitbucket.org:automation-web.git']]])
                 sh "${mvnHome}/bin/mvn compile"
                 sh "${mvnHome}/bin/mvn test"
             }
         }
         }

你不能上台。检查图声明管道:graph