openshiftio / openshift.io

Red Hat OpenShift.io is an end-to-end development environment for planning, building and deploying modern applications.
https://openshift.io
97 stars 66 forks source link

Launcher overwrites existing Jenkinsfile #4155

Open bartoszmajsak opened 6 years ago

bartoszmajsak commented 6 years ago

When importing the project through Launcher, if the Jenkinsfile exists, it is overwritten by the one selected by through the wizard (from https://github.com/fabric8io/fabric8-jenkinsfile-library).

We could potentially solve it be either:

Latter seems to be possible - https://issues.jenkins-ci.org/browse/JENKINS-34561 @lordofthejars @sthaha did you guys checked that? What would be the effort to change build service behaviour?

bartoszmajsak commented 6 years ago

I investigated a bit further the second option.

With not much changes in the launcher code I have both Jenkinsfile in the folder and BuildConfig is pointing to it. So that’s a good news.

  strategy:
    jenkinsPipelineStrategy:
      env:
        - name: FABRIC8_SPACE
          value: booster-tests
      jenkinsfilePath: .openshiftio/Jenkinsfile
    type: JenkinsPipeline

The bad news is that the job itself still executes the one from the root folder. I can get the desired behaviour easily on Minishift with upstream Jenkins service. On OSIO, however, I cannot use Jenkinsfile from the new location. The job simply loads the one from the root of the project. I looked at the job config and it seems that there is a Pipeline Multibranch Plugin installed which still points to the root Jenkinsfile instead.

image

Makes me wonder if that gets precedence. This plugin does not exist in bare-bone OpenShift Jenkins. I don’t have sufficient rights to change this configuration though. So my question is - do we need this plugin? And if we do - how we can change its config based on what we define in the BuildConfig itself.

GeorgeActon commented 6 years ago

@bartoszmajsak I assigned this to build team. If that is wrong, please correct.

bartoszmajsak commented 6 years ago

@GeorgeActon this is actually work needed on Launcher side as well as build team.

jarifibrahim commented 5 years ago

We remove the old jenkinsfile here https://github.com/fabric8-launcher/launcher-backend/blob/050c9a38ecbb0951c8902c6e56f49bff9c0035a0/core/core-impl/src/main/java/io/fabric8/launcher/core/impl/preparers/RemoveOpenshiftioFolderPreparer.java#L37-L43

            // Delete Jenkinsfile if exists
            try {
                Files.deleteIfExists(projectPath.resolve("Jenkinsfile"));
            } catch (IOException e) {
                logger.log(Level.WARNING, "Could not delete Jenkinsfile", e);
            }