this one will work

This commit is contained in:
lenape
2025-03-04 23:39:52 +00:00
parent 6d15f5ee21
commit 7fd6289d5b
2 changed files with 55 additions and 34 deletions

84
Jenkinsfile vendored
View File

@@ -1,35 +1,59 @@
pipeline { pipeline {
agent any agent any
environment { stages {
DOCKERHUB_REPO = 'jacqueskingram/python-jenkins-project'
GITEA_REPO = 'https://code.jacquesingram.online/lenape/python-jenkins-project.git' stage('Build Docker Image') {
steps {
script {
def imageName = "python-jenkins-project:${BUILD_NUMBER}"
sh "DOCKER_BUILDKIT=0 docker build --no-cache -t ${imageName} ."
env.IMAGE_NAME = imageName
}
}
}
stage('Deploy Docker Container') {
steps {
script {
sh "docker stop python-jenkins-container || true"
sh "docker rm python-jenkins-container || true"
sh "docker run -d -p 5555:80 --name python-jenkins-container ${env.IMAGE_NAME}"
}
}
}
stage('Verify Deployment') {
steps {
script {
sh "curl http://38.110.1.139:5555"
}
}
}
} }
stages { }
stage('Build Docker Image') {
steps {
script {
def imageName = "${env.DOCKERHUB_REPO}:${BUILD_NUMBER}"
docker.build(imageName, '.')
env.IMAGE_NAME = imageName
}
}
}
stage('Push to Gitea') {
steps {
git credentialsId: 'my-gitea-credentials', url: "${env.GITEA_REPO}"
sh 'git push origin master'
}
}
stage('Push to Docker Hub') {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'my-dockerhub-credentials') {
docker.image(env.IMAGE_NAME).push()
}
}
}
}
}
}

View File

@@ -19,10 +19,7 @@ pipeline {
stage('Push to Gitea') { stage('Push to Gitea') {
steps { steps {
git credentialsId: 'my-gitea-credentials', url: "${env.GITEA_REPO}" git credentialsId: 'my-gitea-credentials', url: "${env.GITEA_REPO}"
sh ''' sh 'git push origin master'
git checkout -b master
git push origin master
'''
} }
} }
stage('Push to Docker Hub') { stage('Push to Docker Hub') {