Multi-Rag / jenkins
VashuTheGreat2's picture
Upload folder using huggingface_hub
70d4931 verified
pipeline {
agent any
environment {
REPO_URL = "https://github.com/VashuTheGreat/Multi-Rag.git"
PROJECT_NAME = "Multi-Rag"
SPACE_NAME="Multi-Rag"
HF_USERNAME="VashuTheGreat2"
HF_TOKEN = credentials('HF_TOKEN')
}
stages {
stage('Clone Repository') {
steps {
echo "πŸ“₯ Cloning repository..."
git branch: 'main', url: "${REPO_URL}"
}
}
stage('Setup Dependencies') {
steps {
echo "πŸ”§ Setting git identity and installing HF CLI..."
sh '''#!/bin/bash
set -e
git config --global user.name "jenkins"
git config --global user.email "jenkins@local"
export PATH=$HOME/.local/bin:$PATH
if ! command -v hf &> /dev/null; then
pip3 install --user -U huggingface_hub
fi
'''
}
}
stage('Authenticate Hugging Face') {
steps {
echo "πŸ” Logging into Hugging Face..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
hf auth login --token "$HF_TOKEN"
'''
}
}
stage('Configure Space Meta') {
steps {
echo "πŸ“ Injecting HF Spaces configuration into README.md..."
sh '''#!/bin/bash
set -e
TEMP_README=$(mktemp)
cat << EOF > "$TEMP_README"
---
title: $PROJECT_NAME
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: docker
app_file: main.py
pinned: false
short_description: This is the Multi-Rag Agent
---
EOF
cat README.md >> "$TEMP_README"
mv "$TEMP_README" README.md
'''
}
}
stage('Create App Space') {
steps {
echo "πŸš€ Creating HF Space if it doesn't exist..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
hf repos create "$HF_USERNAME/$SPACE_NAME" --type space --space-sdk docker || true
'''
}
}
stage('Upload to HF Space') {
steps {
echo "πŸ“€ Uploading project files..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
hf upload "$HF_USERNAME/$SPACE_NAME" . --repo-type=space
'''
}
}
}
post {
success {
echo "βœ… Pipeline executed successfully!"
}
failure {
echo "❌ Pipeline failed!"
}
}
}