Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42262

Provide a method where extension could implement own logic for the content of custom Config

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The latest (2.15.6) version of the config-file-provider plugin provides an extension point to define an own custom implementation of Config so that the content, MIME type and jelly UI controls can be customized.

      Actually I customise the way to produce the contents of my extension, for example by including the credentials in a format of some kind.
      The only configurations handled are those Maven, because are shipped with the config-file-provider plugin. This is big deal when I would get my custom configuration by use of ConfigFileBuildWrapper because he miss of my custom logic to fill the content.

      To solve this issue in some extension class like ConfigProviderImpl or Config should be added an abstract method that takes in input at least these parameters Run <?,?> Building and TaskListener listener needed to provide the right content at build time with a fallback to the standard Config.content. This changes allow (do not force) also to centralise the provisioning of the configuration file in the right way (token replace, workspace@tmp folder and so on), instead copy/paste the same logic of ManagedFileUtil.provisionConfigFiles to the custom builder/buildwrapper because potentially error prone and are not updated with bug fixes.

      The call sequence in practices

      ManagedFileUtil#provisionConfigFile (can also handle a single ManagedFile)
      -> Config.supplyContent(build, listener)
      -> do the custom elaboration
      -> back content
      -> return the FilePath to the file
      

        Attachments

          Activity

          Hide
          nfalco Nikolas Falco added a comment - - edited

          The main reason of this because until I have jobs that need pure npm commands NodeJS plugin it's sufficient and it provides the config file in the wanted manner.
          But for example there are some other cases where there is javascript code to compile in a maven project (WAR for example). A famous maven plugin (frontend-maven-plugin) provide a very good sandbox for nodejs/npm command and the NodeJS Config is needed to the job to provide an .npmrc that setup the credentials and/or `@scope` registry to an internal npm registry (like artifactory). So I have to setup this .npmrc file in all nodes where runs npm commands in maven build.

          Show
          nfalco Nikolas Falco added a comment - - edited The main reason of this because until I have jobs that need pure npm commands NodeJS plugin it's sufficient and it provides the config file in the wanted manner. But for example there are some other cases where there is javascript code to compile in a maven project (WAR for example). A famous maven plugin (frontend-maven-plugin) provide a very good sandbox for nodejs/npm command and the NodeJS Config is needed to the job to provide an .npmrc that setup the credentials and/or `@scope` registry to an internal npm registry (like artifactory). So I have to setup this .npmrc file in all nodes where runs npm commands in maven build.
          Hide
          imod Dominik Bartholdi added a comment -

          thats a good idea - I'll see what I can do (or more when time allows... )

          Show
          imod Dominik Bartholdi added a comment - thats a good idea - I'll see what I can do (or more when time allows... )
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          src/main/java/org/jenkinsci/lib/configprovider/ConfigProvider.java
          src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFile.java
          src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFile.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java
          src/main/java/org/jenkinsci/plugins/configfiles/common/CleanTempFilesAction.java
          src/main/java/org/jenkinsci/plugins/configfiles/maven/AbstractMavenSettingsProvider.java
          src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnGlobalSettingsProvider.java
          src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnSettingsProvider.java
          src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperTest.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/04fc06917360d1469bedcc22ddabb715f13a4f95
          Log:
          JENKINS-42262 Add public utility that can be used as API by extension
          point to manage provisioning of configuration files that delegate to the
          config provider the business logic of the content.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: src/main/java/org/jenkinsci/lib/configprovider/ConfigProvider.java src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFile.java src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFile.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java src/main/java/org/jenkinsci/plugins/configfiles/common/CleanTempFilesAction.java src/main/java/org/jenkinsci/plugins/configfiles/maven/AbstractMavenSettingsProvider.java src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnGlobalSettingsProvider.java src/main/java/org/jenkinsci/plugins/configfiles/maven/job/MvnSettingsProvider.java src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperTest.java http://jenkins-ci.org/commit/config-file-provider-plugin/04fc06917360d1469bedcc22ddabb715f13a4f95 Log: JENKINS-42262 Add public utility that can be used as API by extension point to manage provisioning of configuration files that delegate to the config provider the business logic of the content.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          src/main/java/org/jenkinsci/lib/configprovider/ConfigProvider.java
          src/main/java/org/jenkinsci/lib/configprovider/model/Config.java
          src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/d93eee55914dcda1cd46952c419cc6ccb7ebeda4
          Log:
          JENKINS-42262 Add a one more EnvVars parameter to ConfigFileManager because a build step could define additional variables used in the config file which otherwise could not be obtained by Token.expandAll() with the usual method Run.getEnvironment(TaskListener)

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: src/main/java/org/jenkinsci/lib/configprovider/ConfigProvider.java src/main/java/org/jenkinsci/lib/configprovider/model/Config.java src/main/java/org/jenkinsci/lib/configprovider/model/ConfigFileManager.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java http://jenkins-ci.org/commit/config-file-provider-plugin/d93eee55914dcda1cd46952c419cc6ccb7ebeda4 Log: JENKINS-42262 Add a one more EnvVars parameter to ConfigFileManager because a build step could define additional variables used in the config file which otherwise could not be obtained by Token.expandAll() with the usual method Run.getEnvironment(TaskListener)
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          pom.xml
          http://jenkins-ci.org/commit/nodejs-plugin/6768686b8d19d8865aee150d3da53e6959eb7a51
          Log:
          JENKINS-42262 Adapts the code to use the new APIs so that config-file-provider could provide the same content file that this plugin produces.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: pom.xml http://jenkins-ci.org/commit/nodejs-plugin/6768686b8d19d8865aee150d3da53e6959eb7a51 Log: JENKINS-42262 Adapts the code to use the new APIs so that config-file-provider could provide the same content file that this plugin produces.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Nikolas Falco
          Path:
          pom.xml
          src/main/java/jenkins/plugins/nodejs/NodeJSBuildWrapper.java
          src/main/java/jenkins/plugins/nodejs/NodeJSCommandInterpreter.java
          src/main/java/jenkins/plugins/nodejs/NodeJSUtils.java
          src/main/java/jenkins/plugins/nodejs/configfiles/NPMConfig.java
          src/test/java/jenkins/plugins/nodejs/NodeJSBuildWrapperTest.java
          src/test/java/jenkins/plugins/nodejs/NpmrcFileSupplyTest.java
          http://jenkins-ci.org/commit/nodejs-plugin/5b7754fd491f15c48f6e0b14a621d586fc5fb6d8
          Log:
          JENKINS-42262 Adapts the code to use the new APIs so that config-file-provider could provide the same content file that this plugin produces.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nikolas Falco Path: pom.xml src/main/java/jenkins/plugins/nodejs/NodeJSBuildWrapper.java src/main/java/jenkins/plugins/nodejs/NodeJSCommandInterpreter.java src/main/java/jenkins/plugins/nodejs/NodeJSUtils.java src/main/java/jenkins/plugins/nodejs/configfiles/NPMConfig.java src/test/java/jenkins/plugins/nodejs/NodeJSBuildWrapperTest.java src/test/java/jenkins/plugins/nodejs/NpmrcFileSupplyTest.java http://jenkins-ci.org/commit/nodejs-plugin/5b7754fd491f15c48f6e0b14a621d586fc5fb6d8 Log: JENKINS-42262 Adapts the code to use the new APIs so that config-file-provider could provide the same content file that this plugin produces.
          Hide
          nfalco Nikolas Falco added a comment -

          released NodeJS 1.2.2 that points to this new APIs

          Show
          nfalco Nikolas Falco added a comment - released NodeJS 1.2.2 that points to this new APIs

            People

            • Assignee:
              domi Dominik Bartholdi
              Reporter:
              nfalco Nikolas Falco
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: