title: Error: name 'variable' is not defined in python+AWS Lambda
body: <p>I am trying to create a lambda function that trigger a jenkins job using python. Below is my python code.</p>
  
  <pre><code>from botocore.vendored import requests
  def lambda_handler(event, context):    
      jenkins_job_name    ="test-job"        
      Jenkins_url         ="http://IP:80"
      jenkins_user        ="test-user"
      jenkins_pwd         ="passwd"
      buildWithParameters =False
      jenkins_params      ={'token': 'xxxxxx', 
                            'result2':'success',
                            'result1': 'success'}
  
  
  try:
      auth= (jenkins_user, jenkins_pwd)
      crumb_data= requests.get("{0}/crumbIssuer/api/json".format(Jenkins_url),auth = auth,headers={'content-type': 'application/json'})
      if str(crumb_data.status_code) == "200":
  
          if buildWithParameters:
              data = requests.get("{0}/job/{1}/buildWithParameters".format(Jenkins_url,jenkins_job_name),auth=auth,params=jenkins_params,headers={'content-type': 'application/json','Jenkins-Crumb':crumb_data.json()['crumb']})
          else:
              data = requests.get("{0}/job/{1}/build".format(Jenkins_url,jenkins_job_name),auth=auth,params=jenkins_params,headers={'content-type': 'application/json','Jenkins-Crumb':crumb_data.json()['crumb']})
  
          if str(data.status_code) == "201":
              print ("Jenkins job is triggered")
          else:
              print ("Failed to trigger the Jenkins job")
  
      else:
          print("Couldn't fetch Jenkins-Crumb")
          raise 
  
  except Exception as e:
      print ("Failed triggering the Jenkins job")
      print ("Error: " + str(e))
  
  </code></pre>
  
  <p>But getting error <strong>"Error: name 'jenkins_user' is not defined"</strong>
  even if The same is already defined in the code.Can someone help me in this?</p>