Sorry, I wasn't clear 

   1. I created a simple maven project 
   (https://github.com/tonymurphy/jenkins-test), *the Jenkins file did not 
   have any checkout step (code sample below*). 
   2. I created a multibranch pipeline project using Jenkins 2. Jenkins 
   then indexed the branches. I was able to use the Jenkins UI to run the build
   3. On running the build, ${mvnHome}/bin/mvn clean compile test failed, 
   the error was pom.xml not found
   4. I determined that the mvn command had been running from the "wrong" 
   directory 
   5. I then had to add the *checkout step*, adding code to check out the 
   branch, add also switch into code check out folder dir("jenkins-test") 
   6. I really like the new Jenkins pipeline - but the additional steps 
   were not obvious and unexpected. I suspect I'm missing something, and my 
   "workaround" is heavy handed
   
-- broken Jenkins file

I hope this makes more sense

Thanks

#!groovy

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 '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'])

            }
        }
    }
}



On Wednesday, August 17, 2016 at 10:44:51 PM UTC+1, Baptiste Mathus wrote:
>
> Not sure I get what your actual issue is. Could you maybe rephrase it to 
> say what you see, compared to what you expect, and provide the error logs 
> and so on?
>
> Cheers
>
> Le 17 août 2016 11:02 AM, "Tony Murphy" <[email protected] <javascript:>> 
> a écrit :
>
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CAORQRkVZKg0fh4oqcgi8CQKhfpJ6BGnBoHijP55xv1SUR2VF6A%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAORQRkVZKg0fh4oqcgi8CQKhfpJ6BGnBoHijP55xv1SUR2VF6A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/d8ea5e81-5de8-4eac-b23b-94213f55e057%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to