Skip to content

Instantly share code, notes, and snippets.

@carsongee
Last active February 15, 2021 14:04
Show Gist options
  • Select an option

  • Save carsongee/0ed0613eaa2d26eed437 to your computer and use it in GitHub Desktop.

Select an option

Save carsongee/0ed0613eaa2d26eed437 to your computer and use it in GitHub Desktop.

Revisions

  1. carsongee revised this gist Dec 30, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions tail_jenkins.py
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    import time


    JENKINS_BASE = "https://jenkins.mitx.mit.edu/job"
    JENKINS_JOB = "Ops/job/docker-sandbox-lavash"
    JENKINS_BASE = "https://example.com"
    JENKINS_JOB = "build-software"


    s = requests.Session()
  2. carsongee revised this gist Dec 24, 2014. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions tail_jenkins.py
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,8 @@
    import time


    JENKINS_BASE = "https://example.com/job"
    JENKINS_JOB = "build-software"
    JENKINS_BASE = "https://jenkins.mitx.mit.edu/job"
    JENKINS_JOB = "Ops/job/docker-sandbox-lavash"


    s = requests.Session()
    @@ -28,9 +28,15 @@
    job_number=sys.argv[1], start=start
    )
    )

    if response.status_code != 200:
    print('Job complete or not found')
    sys.exit(1)

    if start != response.headers['X-Text-Size']:
    print(response.text)
    start = response.headers['X-Text-Size']

    try:
    cont = response.headers['X-More-Data']
    except KeyError:
  3. carsongee revised this gist Dec 24, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions tail_jenkins.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #!/usr/bin/env python
    """
    Tail a Jenkins build in a terminal
    """
  4. carsongee revised this gist Dec 24, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion tail_jenkins.py
    Original file line number Diff line number Diff line change
    @@ -30,5 +30,8 @@
    if start != response.headers['X-Text-Size']:
    print(response.text)
    start = response.headers['X-Text-Size']
    cont = response.headers['X-More-Data']
    try:
    cont = response.headers['X-More-Data']
    except KeyError:
    sys.exit(0)
    time.sleep(2)
  5. carsongee created this gist Dec 24, 2014.
    34 changes: 34 additions & 0 deletions tail_jenkins.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    """
    Tail a Jenkins build in a terminal
    """
    import os
    import requests
    import sys
    import time


    JENKINS_BASE = "https://example.com/job"
    JENKINS_JOB = "build-software"


    s = requests.Session()
    s.auth = (
    os.environ.get('JENKINS_USERNAME', None),
    os.environ.get('JENKINS_PASSWORD', None)
    )

    start = 0
    cont = True
    while cont:
    response = s.get(
    '{base}/{job}/{job_number}'
    '/logText/progressiveText?start={start}'.format(
    base=JENKINS_BASE, job=JENKINS_JOB,
    job_number=sys.argv[1], start=start
    )
    )
    if start != response.headers['X-Text-Size']:
    print(response.text)
    start = response.headers['X-Text-Size']
    cont = response.headers['X-More-Data']
    time.sleep(2)