Added all

This commit is contained in:
Guillem Hernandez Sola
2026-05-20 07:17:06 +02:00
3 changed files with 60 additions and 109 deletions

View File

@@ -57,6 +57,12 @@ pipeline {
pip install --upgrade yt-dlp pip install --upgrade yt-dlp
pip show yt-dlp | grep -E "^(Name|Version)" 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 ─────────────── # ── playwright-stealth version check ───────────────
pip show playwright-stealth | grep -E "^(Name|Version)" pip show playwright-stealth | grep -E "^(Name|Version)"
python3 -c " python3 -c "
@@ -69,12 +75,12 @@ except ImportError:
" "
# ── Sanity checks ────────────────────────────────── # ── Sanity checks ──────────────────────────────────
python3 -c "import atproto; print('atproto OK')" python3 -c "import atproto; print('atproto OK')"
python3 -c "import playwright; print('playwright OK')" python3 -c "import playwright; print('playwright OK')"
python3 -c "import yt_dlp; print('yt_dlp OK')" python3 -c "import yt_dlp; print('yt_dlp OK')"
python3 -c "import httpx; print('httpx OK')" python3 -c "import httpx; print('httpx OK')"
python3 -c "import arrow; print('arrow OK')" python3 -c "import arrow; print('arrow OK')"
python3 -c "import moviepy; print('moviepy OK')" python3 -c "import moviepy; print('moviepy OK')"
# ── System tools ─────────────────────────────────── # ── System tools ───────────────────────────────────
ffmpeg -version | head -1 ffmpeg -version | head -1
@@ -120,6 +126,7 @@ except ImportError:
--tiktok-handle "$TIKTOK_COMEDYGOLDBCN_HANDLE" \ --tiktok-handle "$TIKTOK_COMEDYGOLDBCN_HANDLE" \
--bsky-handle "$BSKY_COMEDYGOLDBCN_HANDLE" \ --bsky-handle "$BSKY_COMEDYGOLDBCN_HANDLE" \
--bsky-app-password "$BSKY_COMEDYGOLDBCN_APP_PASSWORD" \ --bsky-app-password "$BSKY_COMEDYGOLDBCN_APP_PASSWORD" \
--bsky-base-url https://bsky.social \
--bsky-langs ca \ --bsky-langs ca \
--cookies-path tiktok_cookies.json --cookies-path tiktok_cookies.json
''' '''
@@ -156,4 +163,4 @@ except ImportError:
echo '⚠️ TikTok→Bluesky sync finished with warnings.' echo '⚠️ TikTok→Bluesky sync finished with warnings.'
} }
} }
} }

View File

@@ -23,69 +23,31 @@ pipeline {
stage('Setup Python & Install Dependencies') { stage('Setup Python & Install Dependencies') {
steps { steps {
sh ''' 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 ──────────────────────────────────── # Verify that moviepy can be imported
python3 -m venv venv python3 -c "import moviepy" || { echo 'MoviePy import failed!'; exit 1; }
# ── Upgrade pip toolchain ────────────────────────── # Install the local browser binaries for this environment
. venv/bin/activate playwright install chromium
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
''' '''
} }
} }
stage('Run Script') { stage('Run Script') {
steps { steps {
// Securely injects Jenkins credentials as environment variables // Securely injects Jenkins credentials as environment variables

View File

@@ -12,12 +12,6 @@ pipeline {
cron('H/30 * * * *') cron('H/30 * * * *')
} }
environment {
VENV_DIR = 'venv'
PIP_CACHE_DIR = "${WORKSPACE}/.pip-cache"
PYTHONUNBUFFERED = '1'
}
stages { stages {
// ───────────────────────────────────────────── // ─────────────────────────────────────────────
@@ -35,27 +29,20 @@ pipeline {
stage('Setup Python & Install Dependencies') { stage('Setup Python & Install Dependencies') {
steps { steps {
sh ''' sh '''
set -euxo pipefail set -e
# ── 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"
# ── Create venv ──────────────────────────────────── # ── Create venv ────────────────────────────────────
python3 -m venv "${VENV_DIR}" python3 -m venv venv
# ── Upgrade pip toolchain ────────────────────────── # ── 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 ────────────────── # ── Core dependencies ──────────────────────────────
"${VENV_DIR}/bin/pip" install \ pip install -U \
--cache-dir "${PIP_CACHE_DIR}" \
-U \
atproto \ atproto \
playwright \ playwright \
playwright-stealth \
httpx \ httpx \
arrow \ arrow \
python-dotenv \ python-dotenv \
@@ -67,24 +54,18 @@ pipeline {
# ── yt-dlp: always upgrade to latest ────────────── # ── yt-dlp: always upgrade to latest ──────────────
# TikTok extractor breaks frequently — latest is required # TikTok extractor breaks frequently — latest is required
"${VENV_DIR}/bin/pip" install \ pip install --upgrade yt-dlp
--cache-dir "${PIP_CACHE_DIR}" \ pip show yt-dlp | grep -E "^(Name|Version)"
--upgrade \
"yt-dlp"
# Print installed yt-dlp version for traceability # ── curl_cffi: TikTok impersonation (REQUIRED) ─────
"${VENV_DIR}/bin/pip" show yt-dlp | grep -E "^(Name|Version)" # 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 ───────────────────────────── # ── playwright-stealth version check ───────────────
"${VENV_DIR}/bin/pip" install \ pip show playwright-stealth | grep -E "^(Name|Version)"
--cache-dir "${PIP_CACHE_DIR}" \ python3 -c "
-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: try:
from playwright_stealth import stealth_sync from playwright_stealth import stealth_sync
print('playwright_stealth OK (v1.x - stealth_sync)') print('playwright_stealth OK (v1.x - stealth_sync)')
@@ -94,19 +75,19 @@ except ImportError:
" "
# ── Sanity checks ────────────────────────────────── # ── Sanity checks ──────────────────────────────────
"${VENV_DIR}/bin/python" -c "import atproto; print('atproto OK')" python3 -c "import atproto; print('atproto OK')"
"${VENV_DIR}/bin/python" -c "import playwright; print('playwright OK')" python3 -c "import playwright; print('playwright OK')"
"${VENV_DIR}/bin/python" -c "import yt_dlp; print('yt_dlp OK')" python3 -c "import yt_dlp; print('yt_dlp OK')"
"${VENV_DIR}/bin/python" -c "import httpx; print('httpx OK')" python3 -c "import httpx; print('httpx OK')"
"${VENV_DIR}/bin/python" -c "import arrow; print('arrow OK')" python3 -c "import arrow; print('arrow OK')"
"${VENV_DIR}/bin/python" -c "import moviepy; print('moviepy OK')" python3 -c "import moviepy; print('moviepy OK')"
# ── System tools ─────────────────────────────────── # ── System tools ───────────────────────────────────
ffmpeg -version | head -1 ffmpeg -version | head -1
ffprobe -version | head -1 ffprobe -version | head -1
# ── Playwright browser binaries ──────────────────── # ── Playwright browser binaries ────────────────────
"${VENV_DIR}/bin/python" -m playwright install chromium playwright install chromium
''' '''
} }
} }
@@ -135,12 +116,13 @@ except ImportError:
) )
]) { ]) {
sh ''' sh '''
set -euxo pipefail set -e
# Inject the secret cookies file into the workspace # Inject the secret cookies file into the workspace
cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json
"${VENV_DIR}/bin/python" tiktok2bsky.py \ . venv/bin/activate
python3 tiktok2bsky.py \
--tiktok-handle "$TIKTOK_JIJANTESFC_HANDLE" \ --tiktok-handle "$TIKTOK_JIJANTESFC_HANDLE" \
--bsky-handle "$BSKY_JIJANTESFC_HANDLE" \ --bsky-handle "$BSKY_JIJANTESFC_HANDLE" \
--bsky-app-password "$BSKY_JIJANTESFC_APP_PASSWORD" \ --bsky-app-password "$BSKY_JIJANTESFC_APP_PASSWORD" \