Hi

I'm using the new Jenkins Pipelines and I need some help.

I was under the illusion that once I setup my multi branch pipeline that
was it as far as checkouts and branch management was concerned. But it
seems that I was mistaken.

I had issues where for example mvn command was not running in the directory
were the code was checkout out to. The command seemed to be running in a
<branch_name> folder, while the code was in a sibling folder with a
<branch_name>@scripts name (hope that makes sense)

`checkout scm` does not work for me btw

I would be grateful if someone could confirm I'm on the right track, could
suggest improvements or confirm that it won't always be like this :)

#!groovy

githubCredentials = 'github_credentials'
def projectBranch = "${env.BRANCH_NAME}"

node {

    def javaHome = tool "java8" // ensure Java 8 is installed
    def projectRepoURL = '[email protected]:tonymurphy/jenkins-test.git'
    echo "${env.getEnvironment()}"
    def mvnHome  = tool "mvn-3.2.2"

    wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {

        stage "Checkout"
        sh("git config --global credential.helper cache")
        checkout([$class           : 'GitSCM',
                  branches         : [[name: projectBranch]],
                  extensions       : [[$class:
'RelativeTargetDirectory', relativeTargetDir: 'jenkins-test'],
[$class: 'CheckoutOption', timeout: 100000]],
                  userRemoteConfigs: [[credentialsId:
githubCredentials, url: projectRepoURL]]])

        stage 'Build'
        withEnv(["PATH+ACTIVATOR=${tool 'activator-1.3.x'}",
"PATH+JDK=${javaHome}/bin", "JAVA_HOME=${javaHome}"]) {
            dir("jenkins-test") {
                sh "${mvnHome}/bin/mvn clean compile test "
                step([$class: 'ArtifactArchiver', artifacts:
'**/target/*.jar', fingerprint: true])
                step([$class: 'JUnitResultArchiver', testResults:
'**/target/surefire-reports/TEST-*.xml'])

            }
        }
    }
}

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAORQRkVZKg0fh4oqcgi8CQKhfpJ6BGnBoHijP55xv1SUR2VF6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to