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

Unable to use an env. variable for SCM_BRANCH configuration

      I use parametrized Jenkins Build to choise a git branch to build

      In Ansible Tower configuration I refer to this variable

      The environmental variables of my Build containd this Parameter

      But in Ansible Tower I see unresolved variable.

       

      Versions:

      • Ansible-Tower-Plugin: 0.15.0
      • Jenkins: 2.222.3
      • Ansible Tower: 3.6.2

       

       

          [JENKINS-62428] Unable to use an env. variable for SCM_BRANCH configuration

          Alex Pekaliev added a comment -

          We faced same issue with old and new version and to be even more interesting fields like fields like - Job-tags and skip-tags are reporting the variable fine. 

          Seems that only one, which give the string is SCM_BRANCH. 

           

          Alex Pekaliev added a comment - We faced same issue with old and new version and to be even more interesting fields like fields like - Job-tags and skip-tags are reporting the variable fine.  Seems that only one, which give the string is SCM_BRANCH.   

          Alex Pekaliev added a comment -

          Thanks to some debugging and a close eye of a colleague of mine , we do believe the issue resides on a wrongly passed variable.

           

          Here is what the code does on line 106 :

          String expandedScmBranch = envVars.expand(scmBranch);
           

           

          Now, let's see what is actually passed to Tower :

          this.myJob.setJobId(myTowerConnection.submitTemplate(template.getInt("id"), expandedExtraVars, expandedLimit, expandedJobTags, expandedSkipJobTags, jobType, expandedInventory, expandedCredential, scmBranch, templateType));
           

          It should be expandedScmBranch instead of scmBranch. 

          Hopefully will find time next week to recompile (for a first time) a plugin and give it a try. 

          codizz, if you found a different solution - do not hesitate to share it.

          Alex Pekaliev added a comment - Thanks to some debugging and a close eye of a colleague of mine , we do believe the issue resides on a wrongly passed variable.   Here is what the code does on line 106 : String expandedScmBranch = envVars.expand(scmBranch);     Now, let's see what is actually passed to Tower : this.myJob.setJobId(myTowerConnection.submitTemplate(template.getInt("id"), expandedExtraVars, expandedLimit, expandedJobTags, expandedSkipJobTags, jobType, expandedInventory, expandedCredential, scmBranch, templateType));   It should be expandedScmBranch instead of scmBranch.  Hopefully will find time next week to recompile (for a first time) a plugin and give it a try.  codizz , if you found a different solution - do not hesitate to share it.

          Alex Pekaliev added a comment -

          Plugin rebuild led to a successful result. 

          Code was modified to use expandedScmBranch instead of scmBranch when passing the data to Tower.

          Alex Pekaliev added a comment - Plugin rebuild led to a successful result.  Code was modified to use expandedScmBranch instead of scmBranch when passing the data to Tower.

            johnwestcottiv John Westcott
            codizz Georg Koch
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: