diff --git a/jenkins/comedygoldbcnTiktok b/jenkins/comedygoldbcnTiktok index 63d886d..3933f64 100644 --- a/jenkins/comedygoldbcnTiktok +++ b/jenkins/comedygoldbcnTiktok @@ -57,6 +57,12 @@ pipeline { pip install --upgrade yt-dlp pip show yt-dlp | grep -E "^(Name|Version)" + # ── curl_cffi: TikTok impersonation (REQUIRED) ───── + # Without this yt-dlp cannot bypass TikTok bot detection + pip install --upgrade curl-cffi + pip show curl-cffi | grep -E "^(Name|Version)" + python3 -c "import curl_cffi; print('curl_cffi OK')" + # ── playwright-stealth version check ─────────────── pip show playwright-stealth | grep -E "^(Name|Version)" python3 -c " @@ -69,12 +75,12 @@ except ImportError: " # ── Sanity checks ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" + python3 -c "import atproto; print('atproto OK')" + python3 -c "import playwright; print('playwright OK')" + python3 -c "import yt_dlp; print('yt_dlp OK')" + python3 -c "import httpx; print('httpx OK')" + python3 -c "import arrow; print('arrow OK')" + python3 -c "import moviepy; print('moviepy OK')" # ── System tools ─────────────────────────────────── ffmpeg -version | head -1 @@ -120,6 +126,7 @@ except ImportError: --tiktok-handle "$TIKTOK_COMEDYGOLDBCN_HANDLE" \ --bsky-handle "$BSKY_COMEDYGOLDBCN_HANDLE" \ --bsky-app-password "$BSKY_COMEDYGOLDBCN_APP_PASSWORD" \ + --bsky-base-url https://bsky.social \ --bsky-langs ca \ --cookies-path tiktok_cookies.json ''' @@ -156,4 +163,4 @@ except ImportError: echo '⚠️ TikTok→Bluesky sync finished with warnings.' } } -} +} \ No newline at end of file diff --git a/jenkins/comedygoldbcnTw b/jenkins/comedygoldbcnTw index f7e8f2e..86585c9 100644 --- a/jenkins/comedygoldbcnTw +++ b/jenkins/comedygoldbcnTw @@ -23,69 +23,31 @@ pipeline { stage('Setup Python & Install Dependencies') { steps { sh ''' - set -e + set -e # Exit immediately if a command exits with a non-zero status + + # Create a virtual environment named 'venv' + python3 -m venv venv + + # Activate the virtual environment and install dependencies + . venv/bin/activate && \ + pip install --upgrade pip && \ + pip install -U atproto tweety-ns playwright httpx arrow python-dotenv moviepy grapheme + + # Check if moviepy is installed + pip list | grep moviepy || { echo 'MoviePy installation failed!'; exit 1; } + + # Check if FFmpeg is installed + ffmpeg -version || { echo 'FFmpeg is not installed!'; exit 1; } - # ── Create venv ──────────────────────────────────── - python3 -m venv venv + # Verify that moviepy can be imported + python3 -c "import moviepy" || { echo 'MoviePy import failed!'; exit 1; } - # ── Upgrade pip toolchain ────────────────────────── - . venv/bin/activate - pip install --upgrade pip wheel setuptools - - # ── Core dependencies ────────────────────────────── - pip install -U \ - atproto \ - playwright \ - playwright-stealth \ - httpx \ - arrow \ - python-dotenv \ - moviepy \ - beautifulsoup4 \ - charset-normalizer \ - Pillow \ - grapheme - - # ── yt-dlp: always upgrade to latest ────────────── - pip install --upgrade yt-dlp - pip show yt-dlp | grep -E "^(Name|Version)" - - # ── curl_cffi: TikTok impersonation support ──────── - # Required by yt-dlp to bypass TikTok bot detection - pip install --upgrade curl-cffi - pip show curl-cffi | grep -E "^(Name|Version)" - - # ── playwright-stealth version check ─────────────── - pip show playwright-stealth | grep -E "^(Name|Version)" - 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 ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import curl_cffi; print('curl_cffi OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── - playwright install chromium + # Install the local browser binaries for this environment + playwright install chromium ''' } } - stage('Run Script') { steps { // Securely injects Jenkins credentials as environment variables diff --git a/jenkins/jijantesFCTikTok b/jenkins/jijantesFCTikTok index a58f91d..88726d2 100644 --- a/jenkins/jijantesFCTikTok +++ b/jenkins/jijantesFCTikTok @@ -12,12 +12,6 @@ pipeline { cron('H/30 * * * *') } - environment { - VENV_DIR = 'venv' - PIP_CACHE_DIR = "${WORKSPACE}/.pip-cache" - PYTHONUNBUFFERED = '1' - } - stages { // ───────────────────────────────────────────── @@ -35,27 +29,20 @@ pipeline { stage('Setup Python & Install Dependencies') { steps { sh ''' - set -euxo pipefail - - # ── Playwright system dependencies (required in CI) ─ - # Installs libglib, libnss, libatk, libdrm, etc. - # Safe to run even if already installed — exits 0. - "${VENV_DIR}/bin/python" -m playwright install-deps chromium || \ - sudo playwright install-deps chromium || \ - echo "⚠️ playwright install-deps skipped (no sudo) — continuing" + set -e # ── Create venv ──────────────────────────────────── - python3 -m venv "${VENV_DIR}" + python3 -m venv venv # ── Upgrade pip toolchain ────────────────────────── - "${VENV_DIR}/bin/python" -m pip install --upgrade pip wheel setuptools + . venv/bin/activate + pip install --upgrade pip wheel setuptools - # ── Install all required packages ────────────────── - "${VENV_DIR}/bin/pip" install \ - --cache-dir "${PIP_CACHE_DIR}" \ - -U \ + # ── Core dependencies ────────────────────────────── + pip install -U \ atproto \ playwright \ + playwright-stealth \ httpx \ arrow \ python-dotenv \ @@ -67,24 +54,18 @@ pipeline { # ── yt-dlp: always upgrade to latest ────────────── # TikTok extractor breaks frequently — latest is required - "${VENV_DIR}/bin/pip" install \ - --cache-dir "${PIP_CACHE_DIR}" \ - --upgrade \ - "yt-dlp" + pip install --upgrade yt-dlp + pip show yt-dlp | grep -E "^(Name|Version)" - # Print installed yt-dlp version for traceability - "${VENV_DIR}/bin/pip" show yt-dlp | grep -E "^(Name|Version)" + # ── curl_cffi: TikTok impersonation (REQUIRED) ───── + # Without this yt-dlp cannot bypass TikTok bot detection + pip install --upgrade curl-cffi + pip show curl-cffi | grep -E "^(Name|Version)" + python3 -c "import curl_cffi; print('curl_cffi OK')" - # ── playwright-stealth ───────────────────────────── - "${VENV_DIR}/bin/pip" install \ - --cache-dir "${PIP_CACHE_DIR}" \ - -U playwright-stealth - - # Print which version was installed for traceability - "${VENV_DIR}/bin/pip" show playwright-stealth | grep -E "^(Name|Version)" - - # Verify the stealth import works (handles both v1 and v2) - "${VENV_DIR}/bin/python" -c " + # ── playwright-stealth version check ─────────────── + pip show playwright-stealth | grep -E "^(Name|Version)" + python3 -c " try: from playwright_stealth import stealth_sync print('playwright_stealth OK (v1.x - stealth_sync)') @@ -94,19 +75,19 @@ except ImportError: " # ── Sanity checks ────────────────────────────────── - "${VENV_DIR}/bin/python" -c "import atproto; print('atproto OK')" - "${VENV_DIR}/bin/python" -c "import playwright; print('playwright OK')" - "${VENV_DIR}/bin/python" -c "import yt_dlp; print('yt_dlp OK')" - "${VENV_DIR}/bin/python" -c "import httpx; print('httpx OK')" - "${VENV_DIR}/bin/python" -c "import arrow; print('arrow OK')" - "${VENV_DIR}/bin/python" -c "import moviepy; print('moviepy OK')" + python3 -c "import atproto; print('atproto OK')" + python3 -c "import playwright; print('playwright OK')" + python3 -c "import yt_dlp; print('yt_dlp OK')" + python3 -c "import httpx; print('httpx OK')" + python3 -c "import arrow; print('arrow OK')" + python3 -c "import moviepy; print('moviepy OK')" # ── System tools ─────────────────────────────────── ffmpeg -version | head -1 ffprobe -version | head -1 # ── Playwright browser binaries ──────────────────── - "${VENV_DIR}/bin/python" -m playwright install chromium + playwright install chromium ''' } } @@ -135,12 +116,13 @@ except ImportError: ) ]) { sh ''' - set -euxo pipefail + set -e # Inject the secret cookies file into the workspace cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json - "${VENV_DIR}/bin/python" tiktok2bsky.py \ + . venv/bin/activate + python3 tiktok2bsky.py \ --tiktok-handle "$TIKTOK_JIJANTESFC_HANDLE" \ --bsky-handle "$BSKY_JIJANTESFC_HANDLE" \ --bsky-app-password "$BSKY_JIJANTESFC_APP_PASSWORD" \