jenkinsci / pipeline-as-yaml-plugin

Jenkins Pipeline As Yaml Plugin
https://plugins.jenkins.io/pipeline-as-yaml/
MIT License
134 stars 46 forks source link

Parity with standard Jenkinsfile for Docker #42

Open m0un10 opened 3 years ago

m0un10 commented 3 years ago

Is your feature request related to a problem? Please describe.

Since the standard Jenkinsfile doesn't require an explicit clone, pipeline as yaml shouldn't either.

Describe the solution you'd like

When it is yaml from SCM it should automatically have the code cloned (as per the configuration) to be consistent with what happens for Jenkinsfile from SCM.

Describe alternatives you've considered

The workaround is to add an explicit checkout

This works..

pipeline {
    agent { 
        docker { 
            image 'maven:3.3.3' 
            reuseNode true
        }
    }
    stages {
        stage('build') {
            steps {
                sh 'mvn clean package'
            }
        }
    }
}

But this doesn't

pipeline:
  agent:
    docker:
      image: maven:3.3.3
      # 2. Reusing the node (double-check that this doesn't happen automatically)
      reuseNode: 'true'
  stages:
    - stage: "build"
      steps:
        - sh "mvn clean package"

Unless you add a clone step before the maven build

        - "checkout([$class: 'GitSCM', branches: [[name: '*/jenkins-poc']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'example-cred', url: 'https://github.com/example-org/example-repo.git']]])"
m0un10 commented 3 years ago

Maybe this should be a bug instead of feature request but reporting as feature request in case the behaviour is as intended.

aytuncbeken commented 3 years ago

Hi @m0un10 ,

On which job type you are experiencing this problem ? Pipeline or MultiBranch Pipeline ?

m0un10 commented 3 years ago

The issue is with pipeline project when selecting "Pipeline As Yaml from SCM", it won't automatically do the checkout. I've just tested on multi-branch and it seems to be fine.