2016-09-06 2 views
2

아마존 AWS에 리소스를 배포하고있는 jenkins 서버에서 origin/master에 대한 커밋 빌드를 실행 중입니다. 실행 셸 섹션을 사용하여 모든 단위 테스트/linting/유효성 검사/배포를 처리하는 Python 스크립트를 실행하고 배포 (deploy.deploy())에 도달 할 때까지 모든 것이 올바르게 완료되어 킥오프 직후에 성공을 리턴하지만 완료되지 않습니다. 배포. 어떻게이 블록을 만들 수 있습니까?Jenkins git 트리거 빌드되지 않음 차단

실행 쉘 (젠킨스) : 여기에 참고로

내 설정이다

export DEPLOY_REGION=us-west-2 
. build-tools/get_aws_credentials.sh 
python build-tools/kickoff.py 

kickoff.py

if __name__ == "__main__": 
    build_tools_dir="{}".format("/".join(os.path.abspath(__file__).split("/")[0:-1])) 
    sys.path.append(build_tools_dir) 
    base_dir = "/".join(build_tools_dir.split("/")[0:-1]) 
    test_begin = __import__("test_begin") 
    test_all_templates = __import__("test_all_templates") 
    deploy = __import__("deploy") 
    git_plugin = __import__("git_plugin") 
    retval = test_begin.entrypoint("{}/platform/backend".format(base_dir)) 
    if (retval == "SUCCESS"): 
     retval = test_all_templates.entrypoint("{}/platform/backend".format(base_dir)) 
     if (retval == "SUCCESS"): 
      deploy.deploy() 

deploy.py

def deploy(): 
    print(". {}/platform/backend/nu.sh --name jenkinsdeploy --stage dev --keyname greig --debug".format("/".join(os.path.abspath(__file__).split("/")[0:-2]))) 
    returnedcode = subprocess.call("sh {}/platform/backend/nu.sh --name jenkinsdeploy --stage dev --keyname colin_greig --debug".format("/".join(os.path.abspath(__file__).split("/")[0:-2])), shell=True) 
    if returnedcode == 0: 
     return "DEPLOY SUCCESS" 
    return "DEPLOY FAILURE" 
+0

1 분의 수면 while 루프 내부의 상태를 얻을 '에 대한 API 호출을 추가하고 루프 휴식을 경우에만'성공 ' received – chenchuk

+0

파이썬 3의'await' 의미론을 사용할 수도 있습니다. – boardrider

답변

0

aws에 대한 api 호출을 사용하여 상태를 검색하고 '일부 상태'가 될 때까지 대기 할 수 있습니다.

아래의 예는 아이디어를 설명하기 위해 사이비 - 코드 :

import time 
import boto3 
ec2 = boto3.resource('ec2') 

while True: 
    response = ec2.describe_instance_status(.....) 
    if response == 'some status': 
     break 
    time.sleep(60) 

# continue execution