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

          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('') }

          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) }

          Akshat Mehta added a comment -

          Akshat Mehta added a comment - @praveen priyeshnn praveen0528

          Akshat Mehta added a comment -

          Someone pls help if you guys got the solution of this

          Akshat Mehta added a comment - Someone pls help if you guys got the solution of this

          Praveen A added a comment -

          No akshatmehta I didn't get the solution. I left it after the last comment from me. Artifactory repositories refresh is being done manually in my environment.

          Praveen A added a comment - No akshatmehta I didn't get the solution. I left it after the last comment from me. Artifactory repositories refresh is being done manually in my environment.

          Akshat Mehta added a comment -

          Hi,

          Can someone help me on this.

          Akshat Mehta added a comment - Hi, Can someone help me on this.

          Eyal Ben Moshe added a comment - - edited

          The following configurations works for me:

           

          freeStyleJob('seedJobMaven') \{
           wrappers \{
           artifactoryGenericConfigurator \{
           details \{
           artifactoryName('MH-Artifactory')
           artifactoryUrl('https://artifactory.dal.myhrtg.net/artifactory')
           deployReleaseRepository \{
           keyFromText('')
           keyFromSelect('my-repo-local')
           dynamicMode(false)
           }
           deploySnapshotRepository \{
           keyFromText('')
           keyFromSelect('my-repo-local')
           dynamicMode(false)
           }
           resolveReleaseRepository \{
           keyFromText('')
           keyFromSelect('my-repo-virtual')
           dynamicMode(false)
           }
           resolveSnapshotRepository \{
           keyFromText('')
           keyFromSelect('my-repo-virtual')
           dynamicMode(false)
           }
           userPluginKey(null)
           userPluginParams(null)
           }
           resolverDetails(null)
           deployerCredentialsConfig \{
           credentialsId(null)
           username(null)
           password(null)
           overridingCredentials(false)
           }
           resolverCredentialsConfig \{
           credentialsId(null)
           username(null)
           password(null)
           overridingCredentials(false)
           }
           deployBuildInfo(true)
           artifactoryCombinationFilter('')
           envVarsPatterns\{
           includePatterns('*')
           excludePatterns('')
           }
           discardBuildArtifacts(false)
           discardOldBuilds(false)
           customBuildName(null)
           overrideBuildName(false)
           deployPattern('*.tgz')
           resolvePattern('')
           matrixParams(null)
           useSpecs(false)
           uploadSpec \{
           spec(null)
           filePath(null)
           }
           downloadSpec \{
           spec(null)
           filePath(null)
           }
           includeEnvVars(true)
           multiConfProject(false)
           asyncBuildRetention(false)
           }
           }
          }
          
          

          Eyal Ben Moshe added a comment - - edited The following configurations works for me:   freeStyleJob( 'seedJobMaven' ) \{ wrappers \{ artifactoryGenericConfigurator \{ details \{ artifactoryName( 'MH-Artifactory' ) artifactoryUrl( 'https: //artifactory.dal.myhrtg.net/artifactory' ) deployReleaseRepository \{ keyFromText('') keyFromSelect( 'my-repo-local' ) dynamicMode( false ) } deploySnapshotRepository \{ keyFromText('') keyFromSelect( 'my-repo-local' ) dynamicMode( false ) } resolveReleaseRepository \{ keyFromText('') keyFromSelect( 'my-repo-virtual' ) dynamicMode( false ) } resolveSnapshotRepository \{ keyFromText('') keyFromSelect( 'my-repo-virtual' ) dynamicMode( false ) } userPluginKey( null ) userPluginParams( null ) } resolverDetails( null ) deployerCredentialsConfig \{ credentialsId( null ) username( null ) password( null ) overridingCredentials( false ) } resolverCredentialsConfig \{ credentialsId( null ) username( null ) password( null ) overridingCredentials( false ) } deployBuildInfo( true ) artifactoryCombinationFilter('') envVarsPatterns\{ includePatterns( '*' ) excludePatterns('') } discardBuildArtifacts( false ) discardOldBuilds( false ) customBuildName( null ) overrideBuildName( false ) deployPattern( '*.tgz' ) resolvePattern('') matrixParams( null ) useSpecs( false ) uploadSpec \{ spec( null ) filePath( null ) } downloadSpec \{ spec( null ) filePath( null ) } includeEnvVars( true ) multiConfProject( false ) asyncBuildRetention( false ) } } }

          Akshat Mehta added a comment -

          Target repository is still empty after using the above code. 

           

          This part of code is not working

           

          deployReleaseRepository {
          keyFromText('')
          keyFromSelect('my-repo-local')
          dynamicMode(false)
          }

           

          Akshat Mehta added a comment - Target repository is still empty after using the above code.    This part of code is not working   deployReleaseRepository { keyFromText('') keyFromSelect('my-repo-local') dynamicMode(false) }  

          Akshat Mehta added a comment -

          I want this to be present inside target directory space- 'dt-$JOB_NAME/$BUILD_ID'

          for that i am using

          deployReleaseRepository

          { keyFromText('dt-$JOB_NAME/$BUILD_ID') keyFromSelect('') dynamicMode(true) }

          But the field is empty after running dsl script and getting new job.

          Akshat Mehta added a comment - I want this to be present inside target directory space- 'dt-$JOB_NAME/$BUILD_ID' for that i am using deployReleaseRepository { keyFromText('dt-$JOB_NAME/$BUILD_ID') keyFromSelect('') dynamicMode(true) } But the field is empty after running dsl script and getting new job.

          See this answer on Stack Overflow about configuring the Artifactory plugin with Job DSL: https://stackoverflow.com/a/48486303/1271460

          Daniel Spilker added a comment - See this answer on Stack Overflow about configuring the Artifactory plugin with Job DSL: https://stackoverflow.com/a/48486303/1271460

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

              Created:
              Updated:
              Resolved: