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

Provision config files stored in jenkins via pipelines

XMLWordPrintable

      Hello,

      Would there be possible to have the possibility of provisioning config files inside jenkins programmatically (not just from the GUI)? Using groovy syntax via a pipeline?
      For example, I tried doing it by accessing the java classes provided by the plugin, but with no luck (I looked in the source files...but, I have 0 experience in java so that says about all of it)
      I tried something like this:
                          def filePath = 'path/to/new/cfg.file'
                          def gitContent = readFile(filePath).trim()
                          def folder = Jenkins.instance.getItemByFullName(FOLDER_PATH, Folder.class)
                          if (folder == null) {
                              error "Folder not found: ${FOLDER_PATH}"
                          }
                          def store = ConfigFiles.get()
                          def configFile = store.getById(CONFIG_FILE_ID)
                          if (configFile == null)

      {                         error "Config file not found"                     }

                          def newConfig = new CustomConfig(CONFIG_FILE_ID, "cfgfile.properties", "Updated config file", configFile.providerId, gitContent)

                          store.save(newConfig)
      And it didn't work.

      Thanks!

            Unassigned Unassigned
            paul_cli Paul Antonio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: