3Cat TikTok
This commit is contained in:
@@ -14,31 +14,23 @@ pipeline {
|
|||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
// 1. Checkout
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
stage('Checkout Code') {
|
stage('Checkout Code') {
|
||||||
steps {
|
steps {
|
||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
// 2. Python env + dependencies
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
stage('Setup Python & Install Dependencies') {
|
stage('Setup Python & Install Dependencies') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
set -e
|
set -e
|
||||||
|
cd "$WORKSPACE"
|
||||||
|
|
||||||
# ── Create venv ────────────────────────────────────
|
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
|
|
||||||
# ── Upgrade pip toolchain ──────────────────────────
|
"$WORKSPACE/venv/bin/pip" install --upgrade pip wheel setuptools
|
||||||
venv/bin/pip install --upgrade pip wheel setuptools
|
|
||||||
|
|
||||||
# ── Core dependencies ──────────────────────────────
|
"$WORKSPACE/venv/bin/pip" install -U \
|
||||||
venv/bin/pip install -U \
|
|
||||||
atproto \
|
atproto \
|
||||||
playwright \
|
playwright \
|
||||||
playwright-stealth \
|
playwright-stealth \
|
||||||
@@ -49,50 +41,23 @@ pipeline {
|
|||||||
beautifulsoup4 \
|
beautifulsoup4 \
|
||||||
charset-normalizer \
|
charset-normalizer \
|
||||||
Pillow \
|
Pillow \
|
||||||
grapheme
|
grapheme \
|
||||||
|
yt-dlp \
|
||||||
|
curl-cffi
|
||||||
|
|
||||||
# ── yt-dlp: always upgrade to latest ──────────────
|
# Sanity checks
|
||||||
venv/bin/pip install --upgrade yt-dlp
|
"$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')"
|
||||||
venv/bin/pip show yt-dlp | grep -E "^(Name|Version)"
|
"$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) ─────
|
# Playwright browser binaries
|
||||||
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_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
|
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') {
|
stage('Run Script') {
|
||||||
steps {
|
steps {
|
||||||
withCredentials([
|
withCredentials([
|
||||||
@@ -115,12 +80,12 @@ except ImportError:
|
|||||||
]) {
|
]) {
|
||||||
sh '''
|
sh '''
|
||||||
set -e
|
set -e
|
||||||
|
cd "$WORKSPACE"
|
||||||
|
|
||||||
# Inject the secret cookies file into the workspace
|
|
||||||
cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json
|
cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json
|
||||||
|
|
||||||
. venv/bin/activate
|
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
|
||||||
python3 tiktok2bsky.py \
|
"$WORKSPACE/venv/bin/python3" tiktok2bsky.py \
|
||||||
--tiktok-handle "$TIKTOK_3CATEUFORIA_HANDLE" \
|
--tiktok-handle "$TIKTOK_3CATEUFORIA_HANDLE" \
|
||||||
--bsky-handle "$BSKY_3CAT_HANDLE" \
|
--bsky-handle "$BSKY_3CAT_HANDLE" \
|
||||||
--bsky-app-password "$BSKY_3CAT_APP_PASSWORD" \
|
--bsky-app-password "$BSKY_3CAT_APP_PASSWORD" \
|
||||||
@@ -133,32 +98,16 @@ except ImportError:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
// Post actions
|
|
||||||
// ─────────────────────────────────────────────
|
|
||||||
post {
|
post {
|
||||||
|
|
||||||
always {
|
always {
|
||||||
// Archive logs, state, and any debug screenshots
|
|
||||||
archiveArtifacts(
|
archiveArtifacts(
|
||||||
artifacts: '*.log, *.json, screenshot_*.png',
|
artifacts: '*.log, *.json, screenshot_*.png',
|
||||||
allowEmptyArchive: true
|
allowEmptyArchive: true
|
||||||
)
|
)
|
||||||
|
sh 'rm -f "$WORKSPACE/tiktok_cookies.json" || 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.'
|
|
||||||
}
|
}
|
||||||
|
success { echo '✅ Sync cycle completed successfully.' }
|
||||||
|
failure { echo '❌ Sync cycle failed — check archived logs and screenshots.' }
|
||||||
|
unstable { echo '⚠️ Sync cycle finished with warnings.' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user