fix(jenkinsfile): Fix Docker repo name - use username instead of email

This commit is contained in:
Claude AI
2026-01-05 17:29:21 +00:00
parent 07f583966f
commit f3325daa98

View File

@@ -6,9 +6,9 @@ pipeline {
APP_NAME = 'demo-nginx' APP_NAME = 'demo-nginx'
NAMESPACE = 'demo-app' NAMESPACE = 'demo-app'
// Docker registry (измени на свой registry) // Docker registry - ИСПРАВЛЕНО!
DOCKER_REGISTRY = 'docker.io' // Или Harbor: harbor.thedevops.dev DOCKER_REGISTRY = 'docker.io'
DOCKER_REPO = 'vladimir@dbits.lt' // Твой Docker Hub username или Harbor project DOCKER_REPO = 'vladimiras' // Твой Docker Hub USERNAME (не email!)
// Gitea configuration // Gitea configuration
GITEA_URL = 'http://gitea-http.gitea.svc.cluster.local:3000' GITEA_URL = 'http://gitea-http.gitea.svc.cluster.local:3000'
@@ -24,10 +24,7 @@ pipeline {
stage('Checkout Source') { stage('Checkout Source') {
steps { steps {
echo "Checking out application source code..." echo "Checking out application source code..."
// Если у тебя есть отдельный репозиторий с приложением, клонируй его здесь
// git branch: 'main', url: 'http://gitea-http.gitea.svc.cluster.local:3000/admin/demo-nginx-app'
// Для примера, создадим простой Dockerfile
sh ''' sh '''
cat > Dockerfile << 'EOF' cat > Dockerfile << 'EOF'
FROM nginx:1.25.3-alpine FROM nginx:1.25.3-alpine
@@ -35,7 +32,7 @@ FROM nginx:1.25.3-alpine
# Add custom index.html # Add custom index.html
RUN echo "<html><body><h1>Demo Nginx - Build ${BUILD_NUMBER}</h1><p>Environment: Production</p><p>Version: ${IMAGE_TAG}</p></body></html>" > /usr/share/nginx/html/index.html RUN echo "<html><body><h1>Demo Nginx - Build ${BUILD_NUMBER}</h1><p>Environment: Production</p><p>Version: ${IMAGE_TAG}</p></body></html>" > /usr/share/nginx/html/index.html
# Add custom nginx config (optional) # Add custom nginx config
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 EXPOSE 80
@@ -94,7 +91,6 @@ EOF
script { script {
echo "Building Docker image: ${DOCKER_REGISTRY}/${DOCKER_REPO}/${APP_NAME}:${IMAGE_TAG}" echo "Building Docker image: ${DOCKER_REGISTRY}/${DOCKER_REPO}/${APP_NAME}:${IMAGE_TAG}"
// Build image
sh """ sh """
docker build \ docker build \
--build-arg BUILD_NUMBER=${BUILD_NUMBER} \ --build-arg BUILD_NUMBER=${BUILD_NUMBER} \
@@ -112,7 +108,6 @@ EOF
script { script {
echo "Testing Docker image..." echo "Testing Docker image..."
// Run container for testing
sh """ sh """
docker run -d --name test-${BUILD_NUMBER} \ docker run -d --name test-${BUILD_NUMBER} \
-p 8888:80 \ -p 8888:80 \
@@ -142,7 +137,6 @@ EOF
script { script {
echo "Pushing image to registry..." echo "Pushing image to registry..."
// Login to Docker registry
withCredentials([usernamePassword( withCredentials([usernamePassword(
credentialsId: 'docker-registry-credentials', credentialsId: 'docker-registry-credentials',
usernameVariable: 'DOCKER_USER', usernameVariable: 'DOCKER_USER',
@@ -278,9 +272,6 @@ EOF
ArgoCD will automatically sync the changes. ArgoCD will automatically sync the changes.
""" """
// Optional: Send notification to Slack/Teams/Email
// slackSend(color: 'good', message: "Deployment succeeded: ${APP_NAME}:${IMAGE_TAG}")
} }
failure { failure {
@@ -289,9 +280,6 @@ EOF
Please check the logs above for details. Please check the logs above for details.
""" """
// Optional: Send notification
// slackSend(color: 'danger', message: "Deployment failed: ${APP_NAME}:${IMAGE_TAG}")
} }
always { always {