NEw PLaywright
This commit is contained in:
@@ -16,7 +16,6 @@ pipeline {
|
|||||||
|
|
||||||
stage('Checkout Code') {
|
stage('Checkout Code') {
|
||||||
steps {
|
steps {
|
||||||
// Pulls the code from the repository where this Jenkinsfile lives
|
|
||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,34 +23,47 @@ pipeline {
|
|||||||
stage('Setup Python & Install Dependencies') {
|
stage('Setup Python & Install Dependencies') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
set -e # Exit immediately if a command exits with a non-zero status
|
set -e
|
||||||
|
cd "$WORKSPACE"
|
||||||
|
|
||||||
# Create a virtual environment named 'venv'
|
# Crea el venv
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
|
|
||||||
# Activate the virtual environment and install dependencies
|
# Usa python3 -m pip per evitar problemes de shebang amb sh/dash
|
||||||
. venv/bin/activate && \
|
"$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools
|
||||||
pip install --upgrade pip && \
|
|
||||||
pip install -U atproto tweety-ns playwright httpx arrow python-dotenv moviepy grapheme
|
|
||||||
|
|
||||||
# Check if moviepy is installed
|
"$WORKSPACE/venv/bin/python3" -m pip install -U \
|
||||||
pip list | grep moviepy || { echo 'MoviePy installation failed!'; exit 1; }
|
atproto \
|
||||||
|
tweety-ns \
|
||||||
|
playwright \
|
||||||
|
httpx \
|
||||||
|
arrow \
|
||||||
|
python-dotenv \
|
||||||
|
moviepy \
|
||||||
|
grapheme
|
||||||
|
|
||||||
# Check if FFmpeg is installed
|
# Verificació moviepy
|
||||||
ffmpeg -version || { echo 'FFmpeg is not installed!'; exit 1; }
|
"$WORKSPACE/venv/bin/python3" -m pip list | grep moviepy \
|
||||||
|
|| { echo 'MoviePy installation failed!'; exit 1; }
|
||||||
|
|
||||||
# Verify that moviepy can be imported
|
# Verificació FFmpeg
|
||||||
python3 -c "import moviepy" || { echo 'MoviePy import failed!'; exit 1; }
|
ffmpeg -version \
|
||||||
|
|| { echo 'FFmpeg is not installed!'; exit 1; }
|
||||||
|
|
||||||
# Install the local browser binaries for this environment
|
# Verificació imports
|
||||||
playwright install chromium
|
"$WORKSPACE/venv/bin/python3" -c "import moviepy; print('moviepy OK')"
|
||||||
|
"$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')"
|
||||||
|
"$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')"
|
||||||
|
|
||||||
|
# Instal·lació binaris Playwright
|
||||||
|
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
|
||||||
|
"$WORKSPACE/venv/bin/python3" -m playwright install chromium
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Run Script') {
|
stage('Run Script') {
|
||||||
steps {
|
steps {
|
||||||
// Securely inject Jenkins credentials as environment variables
|
|
||||||
withCredentials([
|
withCredentials([
|
||||||
string(credentialsId: 'TWITTER_USERNAME', variable: 'TWITTER_USERNAME'),
|
string(credentialsId: 'TWITTER_USERNAME', variable: 'TWITTER_USERNAME'),
|
||||||
string(credentialsId: 'TWITTER_PASSWORD', variable: 'TWITTER_PASSWORD'),
|
string(credentialsId: 'TWITTER_PASSWORD', variable: 'TWITTER_PASSWORD'),
|
||||||
@@ -61,11 +73,11 @@ pipeline {
|
|||||||
string(credentialsId: 'BSKY_MQUB_PASSWORD', variable: 'BSKY_MQUB_PASSWORD')
|
string(credentialsId: 'BSKY_MQUB_PASSWORD', variable: 'BSKY_MQUB_PASSWORD')
|
||||||
]) {
|
]) {
|
||||||
sh '''
|
sh '''
|
||||||
# Activate the exact same virtual environment so Python finds Playwright and Arrow
|
set -e
|
||||||
. venv/bin/activate
|
cd "$WORKSPACE"
|
||||||
|
|
||||||
# Run the daemon with the injected credentials
|
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
|
||||||
python3 twitter2bsky.py \
|
"$WORKSPACE/venv/bin/python3" twitter2bsky.py \
|
||||||
--twitter-username "$TWITTER_USERNAME" \
|
--twitter-username "$TWITTER_USERNAME" \
|
||||||
--twitter-password "$TWITTER_PASSWORD" \
|
--twitter-password "$TWITTER_PASSWORD" \
|
||||||
--twitter-email "$TWITTER_FCB_EMAIL" \
|
--twitter-email "$TWITTER_FCB_EMAIL" \
|
||||||
@@ -79,4 +91,16 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
archiveArtifacts(
|
||||||
|
artifacts: '*.log, *.json, screenshot_*.png',
|
||||||
|
allowEmptyArchive: true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
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