From 71d5335d30cbc28b47742dd844f3f54f74b27150 Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 09:43:13 +0000 Subject: [PATCH 1/9] add tls verify arg --- jenkins.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jenkins.py b/jenkins.py index 585e375..d211cfe 100644 --- a/jenkins.py +++ b/jenkins.py @@ -34,6 +34,11 @@ def main(arguments): '--jenkins_url', help="Jenkins full URL. example : http://localhost:8080", type=str) + parser.add_argument( + '--tls-verify', + default = True, + help="Enable or disable TLS verification for HTTPS connections", + type=bool) parser.add_argument( '-p', '--param', @@ -61,7 +66,7 @@ def main(arguments): else: start_build_url = '{}/job/{}/build'.format(args.jenkins_url, job_name) - r = requests.post(start_build_url, auth=auth) + r = requests.post(start_build_url, auth=auth, verify=args.tls_verify) if r.status_code // 200 == 1: logging.info('Job "{}" was launched successfully'.format(job_name)) @@ -77,7 +82,7 @@ def main(arguments): logging.info('{} Job {} added to queue: {}'.format(time.ctime(), job_name, job_info_url)) while True: - l = requests.get(job_info_url, auth=auth) + l = requests.get(job_info_url, auth=auth, verify=args.tls_verify) jqe = l.json() task = jqe['task']['name'] try: @@ -99,7 +104,7 @@ def main(arguments): start_epoch = int(time.time()) while True: logging.info("{}: Job started URL: {}".format(time.ctime(), job_url)) - j = requests.get(job_url, auth=auth) + j = requests.get(job_url, auth=auth, verify=args.tls_verify) jje = j.json() result = jje['result'] if result == 'SUCCESS': From 4f1663bd5d81a53b5c02cf2b6b414640b7687b1c Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:26:08 +0000 Subject: [PATCH 2/9] remove unused deps --- jenkins.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/jenkins.py b/jenkins.py index d211cfe..f914145 100644 --- a/jenkins.py +++ b/jenkins.py @@ -3,11 +3,8 @@ This script only support user TOKEN as the password and not the actual user password """ import requests -import re import sys -import json import time -import os import argparse import logging From b1f29a81c49d455ebd5f8e078b8a56243d877bdc Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:26:31 +0000 Subject: [PATCH 3/9] add gh workflows --- .../.github/.workflow/python-release.yml | 40 +++++++++++++++++++ .pipeline/.github/.workflow/test.yaml | 22 ++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .pipeline/.github/.workflow/python-release.yml create mode 100644 .pipeline/.github/.workflow/test.yaml diff --git a/.pipeline/.github/.workflow/python-release.yml b/.pipeline/.github/.workflow/python-release.yml new file mode 100644 index 0000000..b2a4cb4 --- /dev/null +++ b/.pipeline/.github/.workflow/python-release.yml @@ -0,0 +1,40 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Create exec file with Pyinstaller + run: | + pip install pyinstaller + pyinstaller --clean --onefile jenkins.py + continue-on-error: true + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Release + draft: false + prerelease: false \ No newline at end of file diff --git a/.pipeline/.github/.workflow/test.yaml b/.pipeline/.github/.workflow/test.yaml new file mode 100644 index 0000000..23faa30 --- /dev/null +++ b/.pipeline/.github/.workflow/test.yaml @@ -0,0 +1,22 @@ +name: Python test + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Lint with Ruff + run: | + pip install ruff + ruff --output-format=github . + continue-on-error: true From cbe4a13dd3f4571be5278aaef978da89b2431253 Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:27:27 +0000 Subject: [PATCH 4/9] update pull interval --- jenkins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins.py b/jenkins.py index f914145..e67cd40 100644 --- a/jenkins.py +++ b/jenkins.py @@ -9,7 +9,7 @@ import logging QUEUE_POLL_INTERVAL = 2 -JOB_POLL_INTERVAL = 20 +JOB_POLL_INTERVAL = 10 OVERALL_TIMEOUT = 3600 # 1 hour From 37f333be01a1afa406a5777e70e0a312fc10599f Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:33:02 +0000 Subject: [PATCH 5/9] fix path --- {.pipeline/.github => .github}/.workflow/python-release.yml | 0 {.pipeline/.github => .github}/.workflow/test.yaml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {.pipeline/.github => .github}/.workflow/python-release.yml (100%) rename {.pipeline/.github => .github}/.workflow/test.yaml (100%) diff --git a/.pipeline/.github/.workflow/python-release.yml b/.github/.workflow/python-release.yml similarity index 100% rename from .pipeline/.github/.workflow/python-release.yml rename to .github/.workflow/python-release.yml diff --git a/.pipeline/.github/.workflow/test.yaml b/.github/.workflow/test.yaml similarity index 100% rename from .pipeline/.github/.workflow/test.yaml rename to .github/.workflow/test.yaml From 58670c411cbd090a88ba5ecd3d3a613666e926a3 Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:34:19 +0000 Subject: [PATCH 6/9] fix typo --- .github/{.workflow => workflows}/python-release.yml | 0 .github/{.workflow => workflows}/test.yaml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{.workflow => workflows}/python-release.yml (100%) rename .github/{.workflow => workflows}/test.yaml (100%) diff --git a/.github/.workflow/python-release.yml b/.github/workflows/python-release.yml similarity index 100% rename from .github/.workflow/python-release.yml rename to .github/workflows/python-release.yml diff --git a/.github/.workflow/test.yaml b/.github/workflows/test.yaml similarity index 100% rename from .github/.workflow/test.yaml rename to .github/workflows/test.yaml From 9541a7130370844377c371ea8ea5a4bfbe33f7b1 Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:39:47 +0000 Subject: [PATCH 7/9] update job_info_request variable name --- jenkins.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jenkins.py b/jenkins.py index e67cd40..1864a88 100644 --- a/jenkins.py +++ b/jenkins.py @@ -79,13 +79,14 @@ def main(arguments): logging.info('{} Job {} added to queue: {}'.format(time.ctime(), job_name, job_info_url)) while True: - l = requests.get(job_info_url, auth=auth, verify=args.tls_verify) - jqe = l.json() + job_info_request = requests.get(job_info_url, auth=auth, verify=args.tls_verify) + jqe = job_info_request.json() task = jqe['task']['name'] try: job_id = jqe['executable']['number'] + logging.info("job have been launched with the id: {}".format(job_id)) break - except: + except Exception: logging.info("no job ID yet for build: {}".format(task)) time.sleep(QUEUE_POLL_INTERVAL) elasped_time += QUEUE_POLL_INTERVAL @@ -126,7 +127,7 @@ def main(arguments): cur_epoch = int(time.time()) if (cur_epoch - start_epoch) > OVERALL_TIMEOUT: - logging.info("{}: No status before timeout of {} secs".format( + logging.info("No status before timeout of {} secs".format( OVERALL_TIMEOUT)) sys.exit(1) From cdd752a4486e65f172f532d98249c858a4c64d0d Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Mon, 27 May 2024 11:40:50 +0000 Subject: [PATCH 8/9] update ruff cli cmd args --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 23faa30..6d35fdd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,5 +18,5 @@ jobs: - name: Lint with Ruff run: | pip install ruff - ruff --output-format=github . + ruff check --output-format=github . continue-on-error: true From e6f7a92656fd30556bcc35e00595b19aeb7adb01 Mon Sep 17 00:00:00 2001 From: MohamedAnouar <43519543+MohamedAnouar@users.noreply.github.com> Date: Tue, 28 May 2024 12:57:36 +0000 Subject: [PATCH 9/9] update release --- .github/workflows/python-release.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index b2a4cb4..fd886d1 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -10,6 +10,8 @@ jobs: build: name: Create Release runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout code uses: actions/checkout@v2 @@ -25,16 +27,9 @@ jobs: run: | pip install pyinstaller pyinstaller --clean --onefile jenkins.py - continue-on-error: true - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + tar -cvf release.tar.gz dist/ + - uses: ncipollo/release-action@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: | - Release - draft: false - prerelease: false \ No newline at end of file + artifacts: "release.tar.gz" + generateReleaseNotes: true + #bodyFile: "body.md"