Uploaded image for project: 'Bamboo'
  1. Bamboo
  2. BAM-18142

Cannot use Bamboo variable password in Script task

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Low
    • Resolution: Cannot Reproduce
    • 5.14.3.1
    • None
    • None

    Description

      Summary

      • Cannot use Bamboo variable password in Script task

      Environment

      • Bamboo v5.14.3.1

      Steps to Reproduce

      1. add the following Bamboo Variables (It can be on Plan or Global level)
        Variable name Value
        service.username john
        service.password abc123
        service.pwd def456
      2. add a Script task
        echo ${bamboo.service.username}
        echo ${bamboo.service.password}
        echo ${bamboo.service.pwd}
        
        VAR1=${bamboo.service.password}
        echo $VAR1
        
        VAR2=${bamboo.service.pwd}
        echo $VAR2
        

      Expected Results

      VAR1 and VAR2 output the password value.

      Actual Results

      The below exception is thrown in the build log file:

      command	18-Jan-2017 16:39:38	Substituting variable: ${bamboo.service.username} with john
      command	18-Jan-2017 16:39:38	Substituting password variable: ${bamboo.service.password}
      command	18-Jan-2017 16:39:38	Substituting variable: ${bamboo.service.pwd} with ********
      command	18-Jan-2017 16:39:38	Substituting password variable: ${bamboo.service.password}
      command	18-Jan-2017 16:39:38	Substituting variable: ${bamboo.service.pwd} with ********
      simple	18-Jan-2017 16:39:38	Starting task 'Script' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
      ...
      build	18-Jan-2017 16:39:38	john
      build	18-Jan-2017 16:39:38	********
      build	18-Jan-2017 16:39:38	********
      build	18-Jan-2017 16:39:38	********
      build	18-Jan-2017 16:39:38	********
      simple	18-Jan-2017 16:39:38	Finished task 'Script' with result: Success
      

      Further testing

      Put variable into a file

      Script task
      echo ${bamboo.service.username}
      echo ${bamboo.service.password}
      echo ${bamboo.service.pwd}
      
      TEST1=${bamboo.service.password}
      echo $TEST1
      echo $TEST1 > test1.txt
      cat test1.txt
      
      TEST2=${bamboo.service.pwd}
      echo $TEST2
      
      18-Jan-2017 18:56:24	john
      18-Jan-2017 18:56:24	********
      18-Jan-2017 18:56:24	def456
      18-Jan-2017 18:56:24	********
      18-Jan-2017 18:56:24	********
      18-Jan-2017 18:56:24	def456
      
      test1.txt
      abc123
      

      Calling a cURL command

      Script task
      echo ${bamboo.service.username}
      echo ${bamboo.service.password}
      
      TEST1=${bamboo.service.password}
      
      curl -u ${bamboo.service.username}:${bamboo.service.password} \
          -H "Content-type: application/json" -H "Accept: application/json" \
          -X GET "http://localhost:8085/rest/api/latest/plan/PROJ-PLAN"
          
      curl -u ${bamboo.service.username}:$TEST1 \
          -H "Content-type: application/json" -H "Accept: application/json" \
          -X GET "http://localhost:8085/rest/api/latest/plan/PROJ-PLAN"
      
      build	18-Jan-2017 19:04:15	{"expand":"actions,stages,branches,variableContext","projectKey":"PROJ","projectName":"Project","project":{"key":"PROJ","name":"Project","link":{"href":"http://localhost:8085/rest/api/latest/project/PROJ","rel":"self"}},"shortName":"Plan","buildName":"Plan","shortKey":"PLAN","type":"chain","enabled":true,"link":{"href":"http://localhost:8085/rest/api/latest/plan/PROJ-PLAN","rel":"self"},"isFavourite":true,"isActive":true,"isBuilding":true,"averageBuildTimeInSeconds":0.0,"actions":{"size":7,"start-index":0,"max-result":7},"stages":{"size":1,"start-index":0,"max-result":1},"branches":{"size":0,"start-index":0,"max-result":0},"variableContext":{"size":3,"max-results":3},"key":"PROJ-PLAN","name":"Project - Plan","planKey":{"key":"PROJ-PLAN"}}{"expand":"actions,stages,branches,variableContext","projectKey":"PROJ","projectName":"Project","project":{"key":"PROJ","name":"Project","link":{"href":"http://localhost:8085/rest/api/latest/project/PROJ","rel":"self"}},"shortName":"Plan","buildName":"Plan","shortKey":"PLAN","type":"chain","enabled":true,"link":{"href":"http://localhost:8085/rest/api/latest/plan/PROJ-PLAN","rel":"self"},"isFavourite":true,"isActive":true,"isBuilding":true,"averageBuildTimeInSeconds":0.0,"actions":{"size":7,"start-index":0,"max-result":7},"stages":{"size":1,"start-index":0,"max-result":1},"branches":{"size":0,"start-index":0,"max-result":0},"variableContext":{"size":3,"max-results":3},"key":"PROJ-PLAN","name":"Project - Plan","planKey":{"key":"PROJ-PLAN"}}
      

      Calling cURL command from file

      curl.sh
      curl -u ${bamboo_service_username}:${bamboo_service_password} \
          -H "Content-type: application/json" -H "Accept: application/json" \
          -X GET "http://localhost:8085/rest/api/latest/plan/PROJ-PLAN"
      
      Script task
      echo ${bamboo.service.username}
      echo ${bamboo.service.password}
      
      ./curl.sh
      
      build	18-Jan-2017 19:19:36	{"expand":"actions,stages,branches,variableContext","projectKey":"PROJ","projectName":"Project","project":{"key":"PROJ","name":"Project","link":{"href":"http://localhost:8085/rest/api/latest/project/PROJ","rel":"self"}},"shortName":"Plan","buildName":"Plan","shortKey":"PLAN","type":"chain","enabled":true,"link":{"href":"http://localhost:8085/rest/api/latest/plan/PROJ-PLAN","rel":"self"},"isFavourite":true,"isActive":true,"isBuilding":true,"averageBuildTimeInSeconds":0.0,"actions":{"size":7,"start-index":0,"max-result":7},"stages":{"size":1,"start-index":0,"max-result":1},"branches":{"size":0,"start-index":0,"max-result":0},"variableContext":{"size":3,"max-results":3},"key":"PROJ-PLAN","name":"Project - Plan","planKey":{"key":"PROJ-PLAN"}}
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rsperafico Rafael Sperafico (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            18 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: