Fixed Jenkinsfile
This commit is contained in:
@@ -66,12 +66,12 @@ pipeline {
|
||||
# ── 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)')
|
||||
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 ──────────────────────────────────
|
||||
|
||||
@@ -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,46 +54,40 @@ 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 "
|
||||
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)')
|
||||
# ── 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 ──────────────────────────────────
|
||||
"${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
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user