Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add my commited file from my vm #11

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM amazoncorretto:17

WORKDIR /app

COPY target/java-17-maven-project-1.0-SNAPSHOT.jar .

EXPOSE 80

CMD ["java", "-jar", "app.jar"]
55 changes: 55 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
pipeline {
agent any
environment {
DOCKER_TAG = "khaledmohamed447/app-test:${env.BUILD_NUMBER ?: 'latest'}"
}
stages {
stage('Build') {
steps {
script {
sh 'mvn clean package'
}
}
}

stage('Test') {
steps {
script {
sh 'mvn test'
}
}
}

stage('Docker Build and Push') {
steps {
echo 'Building and pushing Docker image...'
withCredentials([usernamePassword(credentialsId: 'my-docker-hub',
usernameVariable: 'DOCKER_USERNAME',
passwordVariable: 'DOCKER_PASSWORD')]) {
script {
sh "docker build -t ${DOCKER_TAG} ."
sh "echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin"
sh "docker push ${DOCKER_TAG}"
}
}
}
}
}
post {
always {
echo 'Pipeline execution completed.'
}
success {
echo 'Pipeline succeeded!'
}
failure {
echo 'Pipeline failed.'
}
cleanup {
script {
echo 'Cleaning up Docker images...'
sh "docker rmi ${DOCKER_TAG} || true"
}
}
}
}
1 change: 1 addition & 0 deletions khaled_hashim.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is the file created from my vm and will be commited