From a252fee0912f220b7323c93b6195c9a8cc7f27ae Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 08:13:27 +0000 Subject: [PATCH 01/23] added new file in the dev1 branch --- dev1.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 dev1.txt diff --git a/dev1.txt b/dev1.txt new file mode 100644 index 0000000..ae4b76f --- /dev/null +++ b/dev1.txt @@ -0,0 +1 @@ +This is the file in the dev1 branch From f2561553d703bb56f6210e7163d2aada21a23b1d Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 08:27:05 +0000 Subject: [PATCH 02/23] added new line in the dev1.txt in dev2 branch --- dev1.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev1.txt b/dev1.txt index ae4b76f..e05e978 100644 --- a/dev1.txt +++ b/dev1.txt @@ -1 +1,3 @@ This is the file in the dev1 branch + +this is the line in the dev2 branch From fc05684b3ace36baee1de8cdc3a21664ff980fbc Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 08:32:16 +0000 Subject: [PATCH 03/23] updated teh line from the dev2 branch --- dev1.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev1.txt b/dev1.txt index e05e978..9237693 100644 --- a/dev1.txt +++ b/dev1.txt @@ -1,3 +1,5 @@ -This is the file in the dev1 branch +This is the file in the dev2 branch this is the line in the dev2 branch + + From 328a0379b1ce3628d8b83c04d62e0283a152b469 Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 13:17:59 +0000 Subject: [PATCH 04/23] added 2nd line in dev1 branch --- dev1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev1.txt b/dev1.txt index 9237693..232225c 100644 --- a/dev1.txt +++ b/dev1.txt @@ -1,5 +1,5 @@ This is the file in the dev2 branch - +this is the 2nd line to check- addin this in dev1 branch this is the line in the dev2 branch From bda7dbca50d7fd3739283d46196c8060ae88f66b Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 13:19:59 +0000 Subject: [PATCH 05/23] added 2nd line in the dev2 branch --- dev1.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev1.txt b/dev1.txt index 9237693..5e58aa9 100644 --- a/dev1.txt +++ b/dev1.txt @@ -1,5 +1,5 @@ This is the file in the dev2 branch - +Checking by ading the new line in the dev2 branch this is the line in the dev2 branch From 3e27bafa7fe83e9a7c5c7188e684147b3f4bcb75 Mon Sep 17 00:00:00 2001 From: Veena Date: Sun, 13 Oct 2024 13:44:39 +0000 Subject: [PATCH 06/23] push.txt created --- push.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 push.txt diff --git a/push.txt b/push.txt new file mode 100644 index 0000000..e69de29 From f1ac18ee5ae76bd6b6319e3d14228776d85a9da2 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sun, 13 Oct 2024 19:27:27 +0530 Subject: [PATCH 07/23] Create pull.txt --- pull.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 pull.txt diff --git a/pull.txt b/pull.txt new file mode 100644 index 0000000..9b646a9 --- /dev/null +++ b/pull.txt @@ -0,0 +1 @@ +This file is for pull request From 309f40087ba070294ff5b94c541118e79d10737a Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 15:07:04 +0530 Subject: [PATCH 08/23] Add files via upload --- ques7.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 ques7.txt diff --git a/ques7.txt b/ques7.txt new file mode 100644 index 0000000..191ef9a --- /dev/null +++ b/ques7.txt @@ -0,0 +1,90 @@ +pipeline { + agent none + parameters { + string defaultValue: 'Jenkins', name: 'env_var1' + choice choices: ['Dev', 'Test', 'Prod'], name: 'env_var2' + booleanParam defaultValue: true, name: 'env_var3' +} + + triggers{ + cron '30 */4 * * *' + pollSCM '30 * * * *' + } + + environment { + MY_STRING = "${params.env_var1}" + MY_CHOICE = "${params.env_var2}" + MY_BOOLEAN = "${params.env_var3}" + } + stages { + + stage('Run on Agent 1') { + agent { label 'java' } + + stages { + stage('Checkout') { + steps { + git branch: 'main', url: 'https://github.com/Veena-devops/java-example.git' + } + } + stage('Test') { + steps { + + echo 'Running unit test and integration test' + echo "Environment Variable MY_STRING: ${MY_STRING}" + echo "Environment Variable MY_CHOICE: ${MY_CHOICE}" + echo "Environment Variable MY_BOOLEAN: ${MY_BOOLEAN}" + } + } + } + } + + + stage('Run on Agent 2') { + agent { label 'Agent-2' } + when { + allOf { + branch 'master' + branch 'dev' + expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } // Only runs if the previous stages succeeded + } + } + stages { + stage('Build') { + when { + expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } // Only runs if the previous stages succeeded + } + steps { + + // Using Global Variables + echo "jobname : '$JOB_NAME'" + echo "build no: '$BUILD_NUMBER'" + echo "job URL: '$BUILD_URL'" + echo "Jenkins URL: '$JENKINS_URL'" + } + } + stage('Push') { + steps { + echo 'Pusing artifact to artifactory' + } + } + } + } + } + + post { + + always { + + emailext body: ''' + jobname : '$JOB_NAME' + build no: '$BUILD_NUMBER' + job URL: '$BUILD_URL' + build status: '$BUILD_STATUS' + + ''', subject: '$JOB_NAME' , from: 'jenkins@example.com', to: 'vlakkamraju11@gmail.com' + +} + + +In cron job, H: This is a Jenkins-specific syntax that stands for "Hash," which Jenkins uses to distribute load evenly across available times. H is used instead of an exact number to allow Jenkins to automatically determine the minute based on a hash of the job name. This means the job won't run at the exact same minute as other jobs with the same */4 frequency, reducing potential resource contention. \ No newline at end of file From 04b3dece9a17e1f87f1b43b6623d746158f2584f Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 15:09:01 +0530 Subject: [PATCH 09/23] Update and rename ques7.txt to ques7 --- ques7.txt => ques7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename ques7.txt => ques7 (96%) diff --git a/ques7.txt b/ques7 similarity index 96% rename from ques7.txt rename to ques7 index 191ef9a..bc8a986 100644 --- a/ques7.txt +++ b/ques7 @@ -87,4 +87,4 @@ pipeline { } -In cron job, H: This is a Jenkins-specific syntax that stands for "Hash," which Jenkins uses to distribute load evenly across available times. H is used instead of an exact number to allow Jenkins to automatically determine the minute based on a hash of the job name. This means the job won't run at the exact same minute as other jobs with the same */4 frequency, reducing potential resource contention. \ No newline at end of file +In cron job, H: This is a Jenkins-specific syntax that stands for "Hash," which Jenkins uses to distribute load evenly across available times. H is used instead of an exact number to allow Jenkins to automatically determine the minute based on a hash of the job name. This means the job won't run at the exact same minute as other jobs with the same */4 frequency, reducing potential resource contention. From 3525d9888954f57296d0ec9492d9d9778fc81c56 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 15:09:42 +0530 Subject: [PATCH 10/23] Update ques7 --- ques7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ques7 b/ques7 index bc8a986..3bd371a 100644 --- a/ques7 +++ b/ques7 @@ -87,4 +87,4 @@ pipeline { } -In cron job, H: This is a Jenkins-specific syntax that stands for "Hash," which Jenkins uses to distribute load evenly across available times. H is used instead of an exact number to allow Jenkins to automatically determine the minute based on a hash of the job name. This means the job won't run at the exact same minute as other jobs with the same */4 frequency, reducing potential resource contention. + From 24040097fdaecc1c999e40534cdc8b3bdd65f9bd Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 15:19:40 +0530 Subject: [PATCH 11/23] Update ques7 --- ques7 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ques7 b/ques7 index 3bd371a..6c85af4 100644 --- a/ques7 +++ b/ques7 @@ -85,6 +85,8 @@ pipeline { ''', subject: '$JOB_NAME' , from: 'jenkins@example.com', to: 'vlakkamraju11@gmail.com' } +} +} From 1a361574e5ad8ab32fc7d8a84bd0de6698851381 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 16:02:17 +0530 Subject: [PATCH 12/23] Update ques7 --- ques7 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ques7 b/ques7 index 6c85af4..df56e5f 100644 --- a/ques7 +++ b/ques7 @@ -46,13 +46,17 @@ pipeline { allOf { branch 'master' branch 'dev' - expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } // Only runs if the previous stages succeeded + expression { + (currentBuild.result == null || currentBuild.result == 'SUCCESS') + } } } stages { stage('Build') { when { - expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } // Only runs if the previous stages succeeded + expression { + (currentBuild.result == null || currentBuild.result == 'SUCCESS') + } } steps { From 904a0e4c75e932faa7e04948052587685dcc2527 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 19:55:05 +0530 Subject: [PATCH 13/23] Update ques7 --- ques7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ques7 b/ques7 index df56e5f..199829d 100644 --- a/ques7 +++ b/ques7 @@ -44,8 +44,8 @@ pipeline { agent { label 'Agent-2' } when { allOf { - branch 'master' - branch 'dev' + branch 'main' + branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') } From e22635076f204fe4435ebd557e9f6437be2a29c7 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:01:07 +0530 Subject: [PATCH 14/23] Update ques7 --- ques7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ques7 b/ques7 index 199829d..f6d0c9a 100644 --- a/ques7 +++ b/ques7 @@ -44,7 +44,7 @@ pipeline { agent { label 'Agent-2' } when { allOf { - branch 'main' + branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') From 161bcb1e49c4ad0e0e29d44aa8aaca30f71d422c Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:06:12 +0530 Subject: [PATCH 15/23] Update ques7 --- ques7 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ques7 b/ques7 index f6d0c9a..3a712c6 100644 --- a/ques7 +++ b/ques7 @@ -43,12 +43,11 @@ pipeline { stage('Run on Agent 2') { agent { label 'Agent-2' } when { - allOf { branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') - } + } } stages { From f7661e444ce623473ca617e2a0fa05ee0c49ac39 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:17:10 +0530 Subject: [PATCH 16/23] Update ques7 --- ques7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ques7 b/ques7 index 3a712c6..9c48fa6 100644 --- a/ques7 +++ b/ques7 @@ -43,7 +43,7 @@ pipeline { stage('Run on Agent 2') { agent { label 'Agent-2' } when { - + branch 'main' branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') From 6528c8f433b58d072cba4acf25d966a8a17ae320 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:20:34 +0530 Subject: [PATCH 17/23] Update ques7 --- ques7 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ques7 b/ques7 index 9c48fa6..792793e 100644 --- a/ques7 +++ b/ques7 @@ -43,7 +43,7 @@ pipeline { stage('Run on Agent 2') { agent { label 'Agent-2' } when { - branch 'main' + branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') From f59d9d7efa727db5d60ec47e994cb3fb0cba6d14 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:50:45 +0530 Subject: [PATCH 18/23] Update ques7 --- ques7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ques7 b/ques7 index 792793e..15b7741 100644 --- a/ques7 +++ b/ques7 @@ -7,8 +7,8 @@ pipeline { } triggers{ - cron '30 */4 * * *' - pollSCM '30 * * * *' + cron '* * * * *' + pollSCM '* * * * *' } environment { From eb4e87d90aa81d3e06f6567bb5b3c33850a141f2 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sat, 2 Nov 2024 20:53:24 +0530 Subject: [PATCH 19/23] Update ques7 --- ques7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ques7 b/ques7 index 15b7741..1a42bcb 100644 --- a/ques7 +++ b/ques7 @@ -7,8 +7,8 @@ pipeline { } triggers{ - cron '* * * * *' - pollSCM '* * * * *' + cron '30 * * * *' + pollSCM '30 * * * *' } environment { From 954ac72d70dddd1c0ba5b591775a8fa9070c5692 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sun, 3 Nov 2024 13:01:23 +0530 Subject: [PATCH 20/23] Update ques7 --- ques7 | 75 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/ques7 b/ques7 index 1a42bcb..496214d 100644 --- a/ques7 +++ b/ques7 @@ -1,3 +1,4 @@ + pipeline { agent none parameters { @@ -12,22 +13,28 @@ pipeline { } environment { + AWS_ACCESS_KEY=credentials('aws_access_key') + GITHUB_CRED=credentials('github_new') MY_STRING = "${params.env_var1}" MY_CHOICE = "${params.env_var2}" MY_BOOLEAN = "${params.env_var3}" } stages { - stage('Run on Agent 1') { - agent { label 'java' } - - stages { - stage('Checkout') { - steps { - git branch: 'main', url: 'https://github.com/Veena-devops/java-example.git' + stage('checkout') { + agent{label 'java'} + when{ + anyOf{ + branch 'main' + branch 'dev1' + } + } + steps { + git branch: 'main', url: 'https://github.com/Veena-devops/java-example.git' } } - stage('Test') { + stage('Test') { + agent{label 'java'} steps { echo 'Running unit test and integration test' @@ -36,28 +43,21 @@ pipeline { echo "Environment Variable MY_BOOLEAN: ${MY_BOOLEAN}" } } - } - } + + - stage('Run on Agent 2') { - agent { label 'Agent-2' } - when { + stage('Build') { + agent {label 'Agent-2'} + when { - branch 'dev1' expression { (currentBuild.result == null || currentBuild.result == 'SUCCESS') - - } - } - stages { - stage('Build') { - when { - expression { - (currentBuild.result == null || currentBuild.result == 'SUCCESS') - } + } + } - steps { + + steps { // Using Global Variables echo "jobname : '$JOB_NAME'" @@ -66,14 +66,25 @@ pipeline { echo "Jenkins URL: '$JENKINS_URL'" } } - stage('Push') { + + stage('Push') { + agent{label 'Agent-2'} + when { + expression { + (currentBuild.result == null || currentBuild.result == 'SUCCESS') + } + } steps { echo 'Pusing artifact to artifactory' + sh 'echo $AWS_ACCESS_KEY' + sh 'echo USERNAME:PASSWORD:: $GITHUB_CRED' + sh 'echo username: $GITHUB_CRED_USR' + sh 'echo password: $GITHUB_CRED_PSW' } } - } - } + } + post { @@ -87,9 +98,13 @@ pipeline { ''', subject: '$JOB_NAME' , from: 'jenkins@example.com', to: 'vlakkamraju11@gmail.com' -} -} -} + } + } + } + + + + From 13b41b3b8addb30a64d1e18cd49900637748a422 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sun, 3 Nov 2024 14:23:41 +0530 Subject: [PATCH 21/23] Add files via upload --- assign pipe10.txt | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 assign pipe10.txt diff --git a/assign pipe10.txt b/assign pipe10.txt new file mode 100644 index 0000000..772fb3d --- /dev/null +++ b/assign pipe10.txt @@ -0,0 +1,83 @@ +pipeline { + agent none + options { + timestamps() + + + } + environment { + + + name='sushmitha' + } + parameters { + string (defaultValue: 'sushmitha', description: 'Enter the username value', name: 'user_name') + choice (name: 'env', choices: ['dev', 'qa', 'prod'],description: 'choose any one') + booleanParam(defaultValue: true, name: 'my_boolean') + } + triggers { + // Periodically trigger every 12 hours + cron('H H/12 * * *') + + // Poll SCM every 15 minutes for changes + pollSCM('H/15 * * * *') + } + + stages { + stage('Stage-1') { + agent { label 'java'} + when{ + anyOf{ + branch 'main' + branch 'dev1' + } + } + steps { + sh 'touch tomcat' + echo "this stage is executing by ${params.user_name}" + echo 'Using Secret Text and Username/Password credentials' + + + } + } + + stage('Stage-2') { + agent { label 'java'} + steps { + sh 'touch master' + echo "executing in ${params.dev}" + echo "my boolean value=${params.my_boolean}" + echo "Executing Stage 2" + // Simulate success; this stage should succeed for Stage 3 to run + } + } + stage('Stage-3') { + agent { label 'Agent-2'} + when { + + expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } + } + + steps { + sh 'touch tomcat' + echo "echo "Job ${env.JOB_NAME} is running on ${env.JENKINS_URL} and having build no: ${env.BUILD_ID}"" //global variable directly we can reference them + echo "Name is: ${name}" /top levl variable,we need to define + echo " echo 'Executing Stage 3 on agent3 (only on master or dev branch after Stage 2 success)'" + } + } + + stage('Stage-4') { + agent { label 'Agent-2'} + when { + // This stage will run only if Stage 3 was successful + expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' } + steps { + echo "executing stage4" + } + } + } + + + } +} +-------------------------------------- \ No newline at end of file From 00e480c1a221de4c26b94db7263f42ea51db202b Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sun, 3 Nov 2024 14:24:10 +0530 Subject: [PATCH 22/23] Update and rename assign pipe10.txt to assign pipe10 --- assign pipe10.txt => assign pipe10 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename assign pipe10.txt => assign pipe10 (94%) diff --git a/assign pipe10.txt b/assign pipe10 similarity index 94% rename from assign pipe10.txt rename to assign pipe10 index 772fb3d..4bee971 100644 --- a/assign pipe10.txt +++ b/assign pipe10 @@ -80,4 +80,4 @@ pipeline { } } --------------------------------------- \ No newline at end of file +-------------------------------------- From 25cb0f10f7333ee94dfee6c098b11e70cfd0fb02 Mon Sep 17 00:00:00 2001 From: Veena-devops Date: Sun, 3 Nov 2024 14:34:42 +0530 Subject: [PATCH 23/23] Update assign pipe10 --- assign pipe10 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assign pipe10 b/assign pipe10 index 4bee971..5c0dbf0 100644 --- a/assign pipe10 +++ b/assign pipe10 @@ -80,4 +80,4 @@ pipeline { } } --------------------------------------- +