From 022a1c01c3feb9ced5b897904080719564b47360 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Wed, 2 Feb 2022 17:16:06 +0530 Subject: [PATCH 01/10] Add files via upload --- jenkins | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 jenkins diff --git a/jenkins b/jenkins new file mode 100644 index 000000000..3cb592acf --- /dev/null +++ b/jenkins @@ -0,0 +1,19 @@ + pipeline { + agent any + stages { + stage('gitclone') { + steps { + sh'''npm i''' + sh'''npm run build''' + } + } + stage('Deploy') { + steps{ + sshagent(credentials : ['barath']) { + sh 'ssh -o StrictHostKeyChecking=no ubuntu@3.20.203.66' + sh 'scp -p -r /var/lib/jenkins/workspace/my-work@2 ubuntu@3.20.203.66:/var/www/html' + } + } + } + } +} \ No newline at end of file From 15cd28e157067c5e41155e0d0023916945e00f24 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Thu, 10 Mar 2022 18:49:42 +0530 Subject: [PATCH 02/10] Rename jenkins to Jenkinsfile --- jenkins => Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename jenkins => Jenkinsfile (95%) diff --git a/jenkins b/Jenkinsfile similarity index 95% rename from jenkins rename to Jenkinsfile index 3cb592acf..51de43b10 100644 --- a/jenkins +++ b/Jenkinsfile @@ -16,4 +16,4 @@ } } } -} \ No newline at end of file +} From ffc21c6bf7879ef105ed69d07934ad05997669f6 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:27:03 +0530 Subject: [PATCH 03/10] Update Jenkinsfile --- Jenkinsfile | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 51de43b10..162428f70 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,19 +1,13 @@ - pipeline { - agent any - stages { - stage('gitclone') { - steps { - sh'''npm i''' - sh'''npm run build''' - } - } - stage('Deploy') { - steps{ - sshagent(credentials : ['barath']) { - sh 'ssh -o StrictHostKeyChecking=no ubuntu@3.20.203.66' - sh 'scp -p -r /var/lib/jenkins/workspace/my-work@2 ubuntu@3.20.203.66:/var/www/html' - } - } - } +node('java-docker-slave'){ + stage('build') { + sh'''apt install nodejs -y''' + sh'''npm install''' + sh'''npm i -g pm2''' + } + stage('direction') { + sh 'cd /root/workspace/demo1' + } + stage('release') { + sh 'pm2 start index.js' } } From d4d68a191b82e2283d4d7d6ce6529dd0a1b9f648 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:36:48 +0530 Subject: [PATCH 04/10] Update Jenkinsfile --- Jenkinsfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 162428f70..1d9366feb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,7 @@ node('java-docker-slave'){ stage('build') { sh'''apt install nodejs -y''' - sh'''npm install''' + sh'''apt install nginx -y''' sh'''npm i -g pm2''' } - stage('direction') { - sh 'cd /root/workspace/demo1' - } - stage('release') { - sh 'pm2 start index.js' - } -} + } From 5498831522003eb45b2db74dd6e2a5f832ab3472 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:38:38 +0530 Subject: [PATCH 05/10] Update Jenkinsfile --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d9366feb..4b40f4529 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,5 @@ node('java-docker-slave'){ stage('build') { sh'''apt install nodejs -y''' - sh'''apt install nginx -y''' - sh'''npm i -g pm2''' + } } - } From ac9990c7b2f04d1cb7d5f44e3c904ad3554f09d7 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Mon, 18 Apr 2022 12:27:32 +0530 Subject: [PATCH 06/10] Create install_dependencies --- install_dependencies | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 install_dependencies diff --git a/install_dependencies b/install_dependencies new file mode 100644 index 000000000..7c0da1f68 --- /dev/null +++ b/install_dependencies @@ -0,0 +1,3 @@ +#!/bin/bash +sudo apt-get update +sudo apt-get -y install nginx From 86a9e8caf44a086751b3116c37fbcac9dd54bed4 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Mon, 18 Apr 2022 12:33:37 +0530 Subject: [PATCH 07/10] Update install_dependencies --- install_dependencies | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_dependencies b/install_dependencies index 7c0da1f68..cebfcb815 100644 --- a/install_dependencies +++ b/install_dependencies @@ -1,3 +1,7 @@ #!/bin/bash sudo apt-get update sudo apt-get -y install nginx +sudo apt-get -y nodejs +sudo apt-get -y npm +sudo npm i -g pm2 +sudo pm2 start app.js From de046a51ae2e2505349a7b8385bd57f29c03f0ae Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Thu, 28 Apr 2022 23:23:11 +0530 Subject: [PATCH 08/10] Update Jenkinsfile --- Jenkinsfile | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4b40f4529..76b4a433b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,23 @@ -node('java-docker-slave'){ - stage('build') { - sh'''apt install nodejs -y''' - } - } + pipeline { + agent any + stages { + stage('gitclone') { + steps { + git 'https://github.com/barathtech/hello-world.git' + sh 'rm -rf .git' + } + } + stage('Deploy') { + steps{ + sshagent(['ssh-key']) { + sh """ + scp -o StrictHostKeyChecking=no -r ${env.WORKSPACE}/* root@10.0.138.24:/var/www/html/${env.JOB_BASE_NAME} + [ -f ".env" ] && scp .env root@10.0.138.24/var/www/html/${env.JOB_BASE_NAME} + ssh -o StrictHostKeyChecking=no root@10.0.138.24 pm2 restart ${env.JOB_BASE_NAME} + """ + + } + } + } + } + } From 8a713713d5ae2608afd074747fb703ae19f2b6eb Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Wed, 11 May 2022 18:45:35 +0530 Subject: [PATCH 09/10] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 54e5fef1f..fc185a2fc 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ const port = process.env.PORT || 3000; const server = http.createServer((req, res) => { res.statusCode = 200; - const msg = 'Hello Node!\n' + const msg = 'Hello new Node!\n' res.end(msg); }); From a30d7004bcf82bc72c7897478d773a66b4c7c3e0 Mon Sep 17 00:00:00 2001 From: Barath <98219666+barathtech@users.noreply.github.com> Date: Tue, 7 Nov 2023 16:11:03 +0530 Subject: [PATCH 10/10] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..a7f2a029c --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,21 @@ +# Node.js with React +# Build a Node.js project that uses React. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript + +trigger: +- master + +pool: + vmImage: ubuntu-latest + +steps: +- task: NodeTool@0 + inputs: + versionSpec: '10.x' + displayName: 'Install Node.js' + +- script: | + npm install + npm run build + displayName: 'npm install and build'