From 7a16e4fbdc3a75f9189bd07a9be3c53a71728ac6 Mon Sep 17 00:00:00 2001 From: ahiresnehal <102793976+ahiresnehal@users.noreply.github.com> Date: Fri, 6 Jan 2023 14:18:03 +0530 Subject: [PATCH 1/4] Create Jenkinsfile --- Jenkinsfile | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..37c2a1b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,82 @@ +pipeline { + agent any + environment { + registry = "docker.io/snehalahire123" + registryCredential = 'dockerhub' + dockerImage = '' + } + stages { + stage('Hello') { + steps { + echo 'Hello World' + } + } + stage('git clone') { + steps { + git credentialsId: 'github', url: 'https://github.com/ahiresnehal/web-app-example.git' + sh 'ls' + sh 'pwd' + } + } + + /* stage('Docker Build and Tag') { + steps { + //sh 'docker build -t nginxt:1.2 .' + //sh 'docker build -t demo2:latest .' + //sh 'docker tag demo2 snehalahire123/demo2:1.2' + //sh 'docker tag nginxte snehalahire123/nginxte:$BUILD_NUMBER' + + sh 'docker build -t mynewapp .' + sh 'docker tag mynewapp snehalahire123/mynewapp' + //sh 'docker tag mynewapp snehalahire123/mynewapp:$BUILD_NUMBER' + } + } + stage('Publish image to Docker Hub') { + steps { + withDockerRegistry([ credentialsId: "dockerhub", url: "" ]) { + sh 'docker push snehalahire123/mynewapp' + //sh 'docker push snehalahire123/mynewapp:$BUILD_NUMBER' + } + } + } + /* stage('deploy to rancher') { + steps { + echo 'continuous deployment' + withKubeConfig([credentialsId: 'rancher', + //caCertificate: '', + serverUrl: 'https://3.109.117.88/k8s/clusters/c-8c5n5', + //contextName: '', + //clusterName: '', + //namespace: '' + ]) { + sh 'kubectl apply -f /var/lib/jenkins/workspace/Final/deploymentservice.yaml' + sh 'kubectl get pods' + } + } + }*/ + + + stage('deploy to rancher') { + steps { + echo 'continuous deployment' + withKubeConfig([credentialsId: 'testconfig']) + { + + //sh 'kubectl get pods' + sh 'kubectl apply -f deploymentservice.yaml' + } + } + } + + + //stage('deploy to rancher') { + //echo 'deployment' + //withKubeConfig([credentialsId: 'rancherkubeconfig', serverUrl: 'https://3.109.117.88']) { + //sh 'kubectl apply -f /var/lib/jenkins/workspace/Final/deploymentservice.yaml' + //sh 'kubectl get pods' + //} + //} + */ + + } + } From 6191fd64b2c6f981ad86802c57dde3ce82d462ca Mon Sep 17 00:00:00 2001 From: ahiresnehal <102793976+ahiresnehal@users.noreply.github.com> Date: Fri, 6 Jan 2023 14:21:39 +0530 Subject: [PATCH 2/4] Update Jenkinsfile --- Jenkinsfile | 60 +---------------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 37c2a1b..b740d40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,64 +19,6 @@ pipeline { } } - /* stage('Docker Build and Tag') { - steps { - //sh 'docker build -t nginxt:1.2 .' - //sh 'docker build -t demo2:latest .' - //sh 'docker tag demo2 snehalahire123/demo2:1.2' - //sh 'docker tag nginxte snehalahire123/nginxte:$BUILD_NUMBER' - - sh 'docker build -t mynewapp .' - sh 'docker tag mynewapp snehalahire123/mynewapp' - //sh 'docker tag mynewapp snehalahire123/mynewapp:$BUILD_NUMBER' - } - } - stage('Publish image to Docker Hub') { - steps { - withDockerRegistry([ credentialsId: "dockerhub", url: "" ]) { - sh 'docker push snehalahire123/mynewapp' - //sh 'docker push snehalahire123/mynewapp:$BUILD_NUMBER' - } - } - } - /* stage('deploy to rancher') { - steps { - echo 'continuous deployment' - withKubeConfig([credentialsId: 'rancher', - //caCertificate: '', - serverUrl: 'https://3.109.117.88/k8s/clusters/c-8c5n5', - //contextName: '', - //clusterName: '', - //namespace: '' - ]) { - sh 'kubectl apply -f /var/lib/jenkins/workspace/Final/deploymentservice.yaml' - sh 'kubectl get pods' - } - } - }*/ - - - stage('deploy to rancher') { - steps { - echo 'continuous deployment' - withKubeConfig([credentialsId: 'testconfig']) - { - - //sh 'kubectl get pods' - sh 'kubectl apply -f deploymentservice.yaml' - } - } - } - - - //stage('deploy to rancher') { - //echo 'deployment' - //withKubeConfig([credentialsId: 'rancherkubeconfig', serverUrl: 'https://3.109.117.88']) { - //sh 'kubectl apply -f /var/lib/jenkins/workspace/Final/deploymentservice.yaml' - //sh 'kubectl get pods' - //} - //} - */ - + } } From 695716b0431e9b2ed2486c941cb82077f2b56635 Mon Sep 17 00:00:00 2001 From: ahiresnehal <102793976+ahiresnehal@users.noreply.github.com> Date: Fri, 6 Jan 2023 14:23:04 +0530 Subject: [PATCH 3/4] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b740d40..070e2a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } stage('git clone') { steps { - git credentialsId: 'github', url: 'https://github.com/ahiresnehal/web-app-example.git' + git credentialsId: 'github1', url: 'https://github.com/ahiresnehal/web-app-example.git' sh 'ls' sh 'pwd' } From 2f71bb27f83a3ae0ec2d6944b9857197a78e1399 Mon Sep 17 00:00:00 2001 From: ahiresnehal <102793976+ahiresnehal@users.noreply.github.com> Date: Fri, 6 Jan 2023 14:26:45 +0530 Subject: [PATCH 4/4] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 070e2a6..ae8a42d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } stage('git clone') { steps { - git credentialsId: 'github1', url: 'https://github.com/ahiresnehal/web-app-example.git' + git credentialsId: 'githubID', url: 'https://github.com/ahiresnehal/web-app-example.git' sh 'ls' sh 'pwd' }