以下是我的代码。我这堂课有问题。这不是完整的代码,只是课程。如果你最后检查if / else条件,我正在调用函数" check_deployment_update_status(JOB_ID)"这是课外的。我在那里遇到问题。
我的代码运行正常,直到该行。但之后我没有得到该功能的输出。所以,我认为函数最终没有被调用。任何人都可以帮助为什么之后if / else操作函数没有被调用。
FYI- 我的代码是做什么的,这个代码在lambda中,并且它集成在codepipeline中。此函数用于从codepipeline到lambda部署到Elastic beanstalk。我正在尝试集成继续令牌,这可以保持继续lambda,因此lambda可以检查它完成,运行或失败的工作状态。如果有人在使用codepipeline和lambda之前做过这个,请发表评论。
class Env():
def start_deployment(self,job_id,cpname):
EB1 = cpname+"1"
EB2 = cpname+"2"
print EB1
print EB2
if cpname.endswith("dev"):
NewEnvName = cpname.replace('dev','qa')
elif cpname.endswith("qa"):
NewEnvName = cpname.replace('qa','stage')
elif cpname.endswith("stage"):
NewEnvName = cpname.replace('stage','prod')
NewEB1 = NewEnvName+"1"
NewEB2 = NewEnvName+"2"
EnvEB1 = client.describe_environments(
EnvironmentNames=[EB1]
)
print EnvEB1
EnvEB2 = client.describe_environments(
EnvironmentNames=[EB2])
print EnvEB2
if EnvEB1['Environments']:
cnameEB1 = EnvEB1['Environments'][0].get('CNAME')
print cnameEB1
if '-blue' in cnameEB1:
CheckVersion = EB2
App_Version = client.describe_environments(EnvironmentNames=[CheckVersion])
print App_Version
VersionLabel = App_Version['Environments'][0]['VersionLabel']
print VersionLabel
elif '-green' in cnameEB1:
CheckVersion = EB1
App_Version = client.describe_environments(EnvironmentNames=[CheckVersion])
print App_Version
VersionLabel = App_Version['Environments'][0]['VersionLabel']
print VersionLabel
EnvEB1 = client.describe_environments(
EnvironmentNames=[NewEB1]
)
print EnvEB1
EnvEB2 = client.describe_environments(
EnvironmentNames=[NewEB2])
print EnvEB2
self.Env = ""
if EnvEB1['Environments']:
cnameEB1 = EnvEB1['Environments'][0].get('CNAME')
print cnameEB1
if '-blue' in cnameEB1:
self.Env = NewEB1
print self.Env
update_env = client.update_environment(
EnvironmentName = self.Env,
VersionLabel = VersionLabel)
print update_env
check_deployment_update_status(job_id)
elif '-green' in cnameEB1:
self.Env = NewEB2
print self.Env
update_env = client.update_environment(
EnvironmentName = self.Env,
VersionLabel = VersionLabel)
print update_env
check_deployment_update_status(job_id)