It would be useful to be able to supply defined configuration files to workflows.

      Possibly it would suffice to make ConfigFileBuildStep be a SimpleBuildStep. CleanTempFilesRunListener cannot be made to work on a flow build (even if you accept any Run there is no guarantee the slave is still online at the end of the flow), so if cleaning files is important then this would better be a block-scoped custom Step.

      Not sure what ConfigFileBuildWrapper is for as distinct from the build step, but probably it would be covered better by a block-scoped step.

          [JENKINS-26339] Workflow integration for Config File Provider

          Stefan Lorenz added a comment -

          Hi, that's my pull request.
          It seems that it's not working correct, because the plugin is using TokenMacro and the constructor wants AbstractBuild.
          I have no idea how to get AbstractBuild from Run which SimpleBuildStep provides...

          Perhaps you can give me a hint...

          Stefan Lorenz added a comment - Hi, that's my pull request. It seems that it's not working correct, because the plugin is using TokenMacro and the constructor wants AbstractBuild. I have no idea how to get AbstractBuild from Run which SimpleBuildStep provides... Perhaps you can give me a hint...

          Jesse Glick added a comment -

          As noted earlier, CleanTempFilesRunListener will not work as is. Assuming this is important, the current PR cannot work (even if token-macro were updated) and so the options are

          1. Make a custom block-scoped Step rather than using SimpleBuildStep.
          2. Wait for JENKINS-24673 to be implemented, probably requiring a new core dependency, and then upgrade ConfigFileBuildWrapper.

          Jesse Glick added a comment - As noted earlier, CleanTempFilesRunListener will not work as is. Assuming this is important, the current PR cannot work (even if token-macro were updated) and so the options are Make a custom block-scoped Step rather than using SimpleBuildStep . Wait for JENKINS-24673 to be implemented, probably requiring a new core dependency, and then upgrade ConfigFileBuildWrapper .

          Jesse Glick added a comment -

          I have implemented the second option. I just realized there is a third: offer the SimpleBuildStep, but issue an error in case the build is not an AbstractBuild and one or more ManagedFile lacks a targetLocation (thus forcing use of temp files). In this case the workflow would be responsible for cleanup:

          node {
            try {
              step([$class: 'ConfigFileBuildStep', managedFiles: [[fileId: 'DefaultMavenSettingsProvider.production', targetLocation: 'settings-prod.xml']]]) {
                sh 'mvn -s settings-prod.xml deploy'
              }
            } finally {
              sh 'rm -f settings-prod.xml'
            }
          }
          

          Not very attractive though.

          Jesse Glick added a comment - I have implemented the second option. I just realized there is a third: offer the SimpleBuildStep , but issue an error in case the build is not an AbstractBuild and one or more ManagedFile lacks a targetLocation (thus forcing use of temp files). In this case the workflow would be responsible for cleanup: node { try { step([$class: 'ConfigFileBuildStep' , managedFiles: [[fileId: 'DefaultMavenSettingsProvider.production' , targetLocation: 'settings-prod.xml' ]]]) { sh 'mvn -s settings-prod.xml deploy' } } finally { sh 'rm -f settings-prod.xml' } } Not very attractive though.

          Is there an ETA for this? It would be very useful for me (short of 'secret files' working in workflows). Thanks!

          E Camden Fisher added a comment - Is there an ETA for this? It would be very useful for me (short of 'secret files' working in workflows). Thanks!

          Jesse Glick added a comment -

          Requires a Jenkins LTS 1.599+ (so, the next one).

          The workaround is to use the Credentials Binding plugin with “secret file” credentials, as I guess you found.

          Jesse Glick added a comment - Requires a Jenkins LTS 1.599+ (so, the next one). The workaround is to use the Credentials Binding plugin with “secret file” credentials, as I guess you found.

          James Nord added a comment -

          jglick Next LTS has been cut

          James Nord added a comment - jglick Next LTS has been cut

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          src/main/java/org/jenkinsci/plugins/configfiles/builder/ConfigFileBuildStep.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java
          src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/bcae9812c08295371a9da9163746f1468b8a744b
          Log:
          JENKINS-26339 SimpleBuildWrapper support.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml src/main/java/org/jenkinsci/plugins/configfiles/builder/ConfigFileBuildStep.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapper.java src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFileUtil.java http://jenkins-ci.org/commit/config-file-provider-plugin/bcae9812c08295371a9da9163746f1468b8a744b Log: JENKINS-26339 SimpleBuildWrapper support.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/workflow-plugin/06d82c91d88fb6a83b99c7354f432bd298297ffa
          Log:
          JENKINS-26339 Noting.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/06d82c91d88fb6a83b99c7354f432bd298297ffa Log: JENKINS-26339 Noting.

          released with 2.9.2

          Dominik Bartholdi added a comment - released with 2.9.2

          Lars Meynberg added a comment -

          Where can I find a config-file-provider example? I've used the Common Wrap step, but I would like to used the more streamlined DSL step.

           try {
                      wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [[fileId: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1429696583138', targetLocation: 'settings.xml', variable: '']]]) {
                          sh 'mvn -s settings.xml clean install -Dmaven.test.failure.ignore'
                      }
          
                  } finally {
                      sh 'rm -f settings.xml'
                  }
          

          Lars Meynberg added a comment - Where can I find a config-file-provider example? I've used the Common Wrap step, but I would like to used the more streamlined DSL step. try { wrap([$class: 'ConfigFileBuildWrapper' , managedFiles: [[fileId: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1429696583138' , targetLocation: 'settings.xml' , variable: '']]]) { sh 'mvn -s settings.xml clean install -Dmaven.test.failure.ignore' } } finally { sh 'rm -f settings.xml' }

            domi Dominik Bartholdi
            jglick Jesse Glick
            Votes:
            5 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: