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

Artifactory dsl code is not loading target repository in the configuration

      Artifactory configuration with dsl as follows. Target repository is empty but config.xml has the value 'libs-snaphost-local'. I attached the screenshot with it. This configuration is for .net

      artifactoryGenericConfigurator {
      details {
      artifactoryName('http://<ip>:<port>/artifactory')
      artifactoryUrl('http://<ip>:<port>/artifactory')
      deployReleaseRepository

      { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) }

      }
      deployPattern('*.zip')
      }

      Above configuration is failing with following error.

      18:10:05 Time Elapsed 00:00:10.80
      18:10:05 For pattern: *.zip 1 artifacts were found
      18:10:06 ERROR: Target repository cannot be empty
      18:10:06 java.lang.IllegalArgumentException: Target repository cannot be empty

          [JENKINS-36303] Artifactory dsl code is not loading target repository in the configuration

          Praveen A created issue -

          Viggo Ahl added a comment - - edited

          Got the same problem as Praveen A. Except that I got the following plugin setup:
          Jenkins 2.12
          Artifactory Plugin 2.5.1
          Job DSL 1.48
          Java 1.8
          OS - Ubuntu

          String artifactory_Name = 'ArtifactoryServer'
          String artifactory_Url = 'http://artifactory.host.se/artifactory'

          artifactoryGenericConfigurator {
          details {
          artifactoryName(artifactory_Name)
          artifactoryUrl(artifactory_Url)
          deployReleaseRepository

          { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true) }

          deploySnapshotRepository

          { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }
          resolveReleaseRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }

          resolveSnapshotRepository

          { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) }

          userPluginKey('')
          userPluginParams('')
          }

          Viggo Ahl added a comment - - edited Got the same problem as Praveen A. Except that I got the following plugin setup: Jenkins 2.12 Artifactory Plugin 2.5.1 Job DSL 1.48 Java 1.8 OS - Ubuntu String artifactory_Name = 'ArtifactoryServer' String artifactory_Url = 'http://artifactory.host.se/artifactory' artifactoryGenericConfigurator { details { artifactoryName(artifactory_Name) artifactoryUrl(artifactory_Url) deployReleaseRepository { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true) } deploySnapshotRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } resolveReleaseRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } resolveSnapshotRepository { keyFromText('node-plugin-snapshots-local') keyFromSelect('') dynamicMode(true) } userPluginKey('') userPluginParams('') }
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 173002 ] New: JNJira + In-Review [ 184874 ]

          Praveen A added a comment -

          Hi eyalbe,

          Any update on this ? It would be very helpful if you provide an alternative way to do this.

          Regards,
          Praveen

          Praveen A added a comment - Hi eyalbe , Any update on this ? It would be very helpful if you provide an alternative way to do this. Regards, Praveen

          Hi,
          The job UI has two fields for the repository selection - a text field and a drop down list. You can choose to configure the repository using one of those fields. The other fields (text or drop down list) may be saved with an empty value in the config.xml. There's another indicator in the config.xml to determine which of the fields to use (when dynamicMode is true, the text fields is used).
          Are you saying that when configuring a repository using the UI, the config.xml does not include the repository key as described above? If this is the case, can you provide the steps to reproduce this issue? Thanks!

          Eyal Ben Moshe added a comment - Hi, The job UI has two fields for the repository selection - a text field and a drop down list. You can choose to configure the repository using one of those fields. The other fields (text or drop down list) may be saved with an empty value in the config.xml. There's another indicator in the config.xml to determine which of the fields to use (when dynamicMode is true, the text fields is used). Are you saying that when configuring a repository using the UI, the config.xml does not include the repository key as described above? If this is the case, can you provide the steps to reproduce this issue? Thanks!

          Praveen A added a comment -

          Hi eyalbe ,

          You didn't get my point. I am using dsl plugin to write config-as-code. If you look at the dsl code which I have provided in the description,

          { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) }

          is given but as attached screenshot, the target repo is not getting loaded with auto generated configuration through the code written.

          I am refreshing repositories manually in the configuration and choosing the value currently due to this issue.

          Praveen A added a comment - Hi eyalbe , You didn't get my point. I am using dsl plugin to write config-as-code. If you look at the dsl code which I have provided in the description, { keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) } is given but as attached screenshot, the target repo is not getting loaded with auto generated configuration through the code written. I am refreshing repositories manually in the configuration and choosing the value currently due to this issue.

          priyesh nn added a comment -

          Any updated on this issue

          priyesh nn added a comment - Any updated on this issue

          Here's whay this is happening:
          The snippet in this issue includes the following:

          keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false)

          Notice that "dynamicMode" is set to false. It means that build expects "keyFromSelect" to have the repository value, but instead it is empty, That's the reason why the build is failing with "Target repository cannot be empty".
          For the above example, the DSL can be fixed in one of the following ways:
          Change "dynamicMode(false)" to "dynamicMode(true)"
          OR
          Change "keyFromSelect('')" to keyFromSelect('libs-snapshot-local'')

          Please let me know if this helps.

          Eyal Ben Moshe added a comment - Here's whay this is happening: The snippet in this issue includes the following: keyFromText('libs-snapshot-local') keyFromSelect('') dynamicMode(false) Notice that "dynamicMode" is set to false. It means that build expects "keyFromSelect" to have the repository value, but instead it is empty, That's the reason why the build is failing with "Target repository cannot be empty". For the above example, the DSL can be fixed in one of the following ways: Change "dynamicMode(false)" to "dynamicMode(true)" OR Change "keyFromSelect('')" to keyFromSelect('libs-snapshot-local'') Please let me know if this helps.

          Praveen A added a comment - - edited

          No eyalbe, It didn't help either.

          I actually tried these combinations first time itself but never worked out.

          Please let me know what config-as-code is working for you at your environment.

          Thanks,
          Praveen

          Praveen A added a comment - - edited No eyalbe , It didn't help either. I actually tried these combinations first time itself but never worked out. Please let me know what config-as-code is working for you at your environment. Thanks, Praveen

          Akshat Mehta added a comment - - edited

          HI eyalb,

           

          I am encountering the same problem while trying to automate the job creation process.

          Target repository field is empty after trying multiple times.

          below is the code I am using.

           

          Any solutions how that value can be populated, or any other way to integrate DSL with artifactory that solves the problem.

          I could not find any help on google and ended up with this same issue discussed here.

          I am using the latest version of DSL plugin .

           

           

           

          configure { project ->
          project / buildWrappers << 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator' {
          details {

          artifactoryUrl('abc')
          artifactoryName('abc')

          deployReleaseRepository

          {

          keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true)

           

          {color:#ff0000}}

          }
          deployPattern('.zip ')
          matrixParams('')
          deployBuildInfo(true)
          includeEnvVars(true)
          envVarsPatterns {
          includePatterns('')
          excludePatterns('password,secret,key')
          }
          discardOldBuilds(true)
          discardBuildArtifacts(true)

          }

          Akshat Mehta added a comment - - edited HI eyalb ,   I am encountering the same problem while trying to automate the job creation process. Target repository field is empty after trying multiple times. below is the code I am using.   Any solutions how that value can be populated, or any other way to integrate DSL with artifactory that solves the problem. I could not find any help on google and ended up with this same issue discussed here. I am using the latest version of DSL plugin .       configure { project -> project / buildWrappers << 'org.jfrog.hudson.generic.ArtifactoryGenericConfigurator' { details { artifactoryUrl('abc') artifactoryName('abc') deployReleaseRepository { keyFromText('node-plugin-release-local') keyFromSelect('') dynamicMode(true)   {color:#ff0000}} } deployPattern('.zip ') matrixParams('') deployBuildInfo(true) includeEnvVars(true) envVarsPatterns { includePatterns('') excludePatterns(' password , secret , key ') } discardOldBuilds(true) discardBuildArtifacts(true) }

            daspilker Daniel Spilker
            praveen0528 Praveen A
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: