From 4342adc48adb303b429f2ac8d870056716242b2e Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Tue, 30 Jun 2026 15:44:34 +0200 Subject: [PATCH] 3Cat TikTok --- jenkins/3CatEuforiaTikTok | 91 +++++++++------------------------------ 1 file changed, 20 insertions(+), 71 deletions(-) diff --git a/jenkins/3CatEuforiaTikTok b/jenkins/3CatEuforiaTikTok index db7f971..75536f3 100644 --- a/jenkins/3CatEuforiaTikTok +++ b/jenkins/3CatEuforiaTikTok @@ -14,31 +14,23 @@ pipeline { stages { - // ───────────────────────────────────────────── - // 1. Checkout - // ───────────────────────────────────────────── stage('Checkout Code') { steps { checkout scm } } - // ───────────────────────────────────────────── - // 2. Python env + dependencies - // ───────────────────────────────────────────── stage('Setup Python & Install Dependencies') { steps { sh ''' set -e + cd "$WORKSPACE" - # ── Create venv ──────────────────────────────────── python3 -m venv venv - # ── Upgrade pip toolchain ────────────────────────── - venv/bin/pip install --upgrade pip wheel setuptools + "$WORKSPACE/venv/bin/pip" install --upgrade pip wheel setuptools - # ── Core dependencies ────────────────────────────── - venv/bin/pip install -U \ + "$WORKSPACE/venv/bin/pip" install -U \ atproto \ playwright \ playwright-stealth \ @@ -49,50 +41,23 @@ pipeline { beautifulsoup4 \ charset-normalizer \ Pillow \ - grapheme + grapheme \ + yt-dlp \ + curl-cffi - # ── yt-dlp: always upgrade to latest ────────────── - venv/bin/pip install --upgrade yt-dlp - venv/bin/pip show yt-dlp | grep -E "^(Name|Version)" + # Sanity checks + "$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')" + "$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')" + "$WORKSPACE/venv/bin/python3" -c "import yt_dlp; print('yt_dlp OK')" + "$WORKSPACE/venv/bin/python3" -c "import curl_cffi; print('curl_cffi OK')" - # ── curl_cffi: TikTok impersonation (REQUIRED) ───── - venv/bin/pip install --upgrade curl-cffi - venv/bin/pip show curl-cffi | grep -E "^(Name|Version)" - venv/bin/python3 -c "import curl_cffi; print('curl_cffi OK')" - - # ── playwright-stealth version check ─────────────── - venv/bin/pip show playwright-stealth | grep -E "^(Name|Version)" - venv/bin/python3 -c " -try: - from playwright_stealth import stealth_sync - print('playwright_stealth OK (v1.x - stealth_sync)') -except ImportError: - from playwright_stealth import Stealth - print('playwright_stealth OK (v2.x - Stealth class)') -" - - # ── Sanity checks ────────────────────────────────── - venv/bin/python3 -c "import atproto; print('atproto OK')" - venv/bin/python3 -c "import playwright; print('playwright OK')" - venv/bin/python3 -c "import yt_dlp; print('yt_dlp OK')" - venv/bin/python3 -c "import httpx; print('httpx OK')" - venv/bin/python3 -c "import arrow; print('arrow OK')" - venv/bin/python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── + # Playwright browser binaries PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ - venv/bin/playwright install chromium + "$WORKSPACE/venv/bin/playwright" install chromium ''' } } - // ───────────────────────────────────────────── - // 3. Run the bot - // ───────────────────────────────────────────── stage('Run Script') { steps { withCredentials([ @@ -115,12 +80,12 @@ except ImportError: ]) { sh ''' set -e + cd "$WORKSPACE" - # Inject the secret cookies file into the workspace cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json - . venv/bin/activate - python3 tiktok2bsky.py \ + PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ + "$WORKSPACE/venv/bin/python3" tiktok2bsky.py \ --tiktok-handle "$TIKTOK_3CATEUFORIA_HANDLE" \ --bsky-handle "$BSKY_3CAT_HANDLE" \ --bsky-app-password "$BSKY_3CAT_APP_PASSWORD" \ @@ -133,32 +98,16 @@ except ImportError: } } - // ───────────────────────────────────────────── - // Post actions - // ───────────────────────────────────────────── post { - always { - // Archive logs, state, and any debug screenshots archiveArtifacts( artifacts: '*.log, *.json, screenshot_*.png', allowEmptyArchive: true ) - - // Remove injected cookies file — never leave on disk between runs - sh 'rm -f tiktok_cookies.json || true' - } - - success { - echo '✅ Sync cycle completed successfully.' - } - - failure { - echo '❌ Sync cycle failed — check archived logs and screenshots.' - } - - unstable { - echo '⚠️ Sync cycle finished with warnings.' + sh 'rm -f "$WORKSPACE/tiktok_cookies.json" || true' } + success { echo '✅ Sync cycle completed successfully.' } + failure { echo '❌ Sync cycle failed — check archived logs and screenshots.' } + unstable { echo '⚠️ Sync cycle finished with warnings.' } } } \ No newline at end of file