From 1573bf3f55cea6864494c62b43575409a9c7ba9c Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 11:13:53 +0530
Subject: [PATCH 01/33] Ammended the license
---
LICENSE | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LICENSE b/LICENSE
index 94a9ed0..f0091f0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Prfeamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
From 6a6df91267c5338586e6dcdf703ecc471af5356f Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 11:15:50 +0530
Subject: [PATCH 02/33] Update pom.xml
---
maven-profiles/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-profiles/pom.xml b/maven-profiles/pom.xml
index 11a6d09..15d4961 100644
--- a/maven-profiles/pom.xml
+++ b/maven-profiles/pom.xml
@@ -9,7 +9,7 @@
pom
1.0
-
+ >
example1
example2
From ce679b7ad49d0d958557c1241d2176ad26d8f533 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 11:17:56 +0530
Subject: [PATCH 03/33] Reverting the modules in pom
---
maven-profiles/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-profiles/pom.xml b/maven-profiles/pom.xml
index 15d4961..11a6d09 100644
--- a/maven-profiles/pom.xml
+++ b/maven-profiles/pom.xml
@@ -9,7 +9,7 @@
pom
1.0
- >
+
example1
example2
From 5ca6782296e2d5af74cd0480a755118c82ae03a9 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 12:35:13 +0530
Subject: [PATCH 04/33] Modules updated in pom.xml
---
maven-profiles/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-profiles/pom.xml b/maven-profiles/pom.xml
index 11a6d09..15d4961 100644
--- a/maven-profiles/pom.xml
+++ b/maven-profiles/pom.xml
@@ -9,7 +9,7 @@
pom
1.0
-
+ >
example1
example2
From 872f09110b10d90f5a259a06451d272c39049a1b Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 12:42:03 +0530
Subject: [PATCH 05/33] Create Jenkinsfile
---
Jenkinsfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 Jenkinsfile
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..9bf244f
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,47 @@
+pipeline {
+ agent { label "master" }
+
+ triggers {
+ cron('* * * * 1-5')
+ }
+
+ options {
+ skipDefaultCheckout true // Allows us to clean house before actual git pull
+ }
+
+ environment { // A good place to put high visibility/commit-changing variables
+ SLACK_MESSAGE_CHANNEL = "slack-testing"
+ SLACK_SUCCESS_COLOR = "#00FF00" // Green
+ SLACK_UNSTABLE_COLOR = "#FFFF00" // Yellow
+ SLACK_FAIL_COLOR = "#FF0000" // Red
+ CONFIG_FILE_NAME = "config.xml"
+ }
+
+ stages {
+ stage ("Initialization") {
+ steps {
+ cleanWs() // Clean house
+ }
+ }
+ stage ("Find and Copy config file") {
+ steps {
+ sh 'pwd && ls -ltr && git config --global user.email "ci-admin@jenkins.com" && git config user.name "CI Admin"'
+ }
+
+ post {
+ failure {
+ slackSend (color: '#FF0000', message: """FAILED:
+Job: ${env.JOB_NAME}
+Build #${env.BUILD_NUMBER}
+Build: ${env.BUILD_URL}'""")
+ }
+ success {
+ slackSend (color: '#00FF00', message: """SUCCESS:
+Job: ${env.JOB_NAME}
+Build #${env.BUILD_NUMBER}
+Build: ${env.BUILD_URL}'""")
+ }
+ }
+ }
+ }
+}
From 327442db2cca3703a2525adc7611c8ec24276780 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 12:57:53 +0530
Subject: [PATCH 06/33] Update Jenkinsfile
---
Jenkinsfile | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 9bf244f..682615b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,10 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'pwd && ls -ltr && git config --global user.email "ci-admin@jenkins.com" && git config user.name "CI Admin"'
+ withCredentials(usernamePassword(){
+ // Get some code from a GitHub repository
+ sh("""
+ git config --global user.email "ci-admin@jenkins.com" && git config --global git config user.name "CI Admin" && git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test""")
}
post {
From fca9916d98094cb3cd23bcf80c53e9e68384e12f Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:03:05 +0530
Subject: [PATCH 07/33] Updated the maven test
---
Jenkinsfile | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 682615b..6ed94c4 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,11 +25,9 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- withCredentials(usernamePassword(){
- // Get some code from a GitHub repository
- sh("""
- git config --global user.email "ci-admin@jenkins.com" && git config --global git config user.name "CI Admin" && git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test""")
- }
+ sh 'git config --global user.email "ci-admin@jenkins.com" && git config --global git config user.name "CI Admin" && git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test'
+ }
+
post {
failure {
From 1c5b2c8c7e429c0b798eb95eea5449b605b50538 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:04:26 +0530
Subject: [PATCH 08/33] Adding maven deployment script
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 6ed94c4..161441d 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,7 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'git config --global user.email "ci-admin@jenkins.com" && git config --global git config user.name "CI Admin" && git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test'
+ sh 'git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test && mvn install'
}
From f81cfa68ba8ed4ac570ede0fe6ff54181eb7cd08 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:06:02 +0530
Subject: [PATCH 09/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 161441d..ac9f8a8 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,7 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'git clone https://github.com/ziyanakthar/maven-examples.git && cd maven-unit-test && mvn test && mvn install'
+ sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd & ls -ltr && cd maven-examples/maven-unit-test && mvn test && mvn install'
}
From 5ca2768d3c822c771f04e7b1d4a9aec0078464ba Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:08:42 +0530
Subject: [PATCH 10/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index ac9f8a8..c9f24da 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,7 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd & ls -ltr && cd maven-examples/maven-unit-test && mvn test && mvn install'
+ sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd & ls -ltr maven-examples/ && cd maven-examples/maven-unit-test && mvn test && mvn install'
}
From 0914721133e104abf9607aa13ef0df39c32f4c59 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:10:45 +0530
Subject: [PATCH 11/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index c9f24da..5b3f1aa 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,7 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd & ls -ltr maven-examples/ && cd maven-examples/maven-unit-test && mvn test && mvn install'
+ sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd && cd maven-examples && ls -ltr && mvn test && mvn install'
}
From 3d73e2713773de7953d26470d29ee8ba0538db05 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:12:55 +0530
Subject: [PATCH 12/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 5b3f1aa..b30d232 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -25,7 +25,7 @@ pipeline {
}
stage ("Find and Copy config file") {
steps {
- sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd && cd maven-examples && ls -ltr && mvn test && mvn install'
+ sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd && cd maven-examples/maven-unit-test && ls -ltr && mvn test && mvn install'
}
From b365518ea1a98bd35fc0357e65cfd0bbfad62e59 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 13:15:52 +0530
Subject: [PATCH 13/33] Update Jenkinsfile
---
Jenkinsfile | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index b30d232..30abe6b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,9 +1,7 @@
pipeline {
agent { label "master" }
- triggers {
- cron('* * * * 1-5')
- }
+ triggers { pollSCM 'H/5 * * * *' }
options {
skipDefaultCheckout true // Allows us to clean house before actual git pull
@@ -23,7 +21,7 @@ pipeline {
cleanWs() // Clean house
}
}
- stage ("Find and Copy config file") {
+ stage ("Maven Tests") {
steps {
sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd && cd maven-examples/maven-unit-test && ls -ltr && mvn test && mvn install'
}
From 126618602cd5cf5de3fe98b5e469f5945aaed7e2 Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 9 Nov 2021 12:59:54 +0000
Subject: [PATCH 14/33] Updated the READEM
---
README.md | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.md b/README.md
index c302f6f..2b2354f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-## Apache Maven Tutorial
Source code for mkyong.com Apache Maven tutorial
-https://www.mkyong.com/tutorials/maven-tutorials/
\ No newline at end of file
+https://www.mkyong.com/tutorials/maven-tutorials/
From 71cfbf3b0a9c4e26472cacd3f841e585399c74e1 Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 9 Nov 2021 13:00:24 +0000
Subject: [PATCH 15/33] Updated the pom.xml
---
maven-unit-test/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-unit-test/pom.xml b/maven-unit-test/pom.xml
index 21bc2e3..24d0188 100644
--- a/maven-unit-test/pom.xml
+++ b/maven-unit-test/pom.xml
@@ -25,7 +25,7 @@
5.3.1
test
-
+
maven-unit-test
From 59b6e3296c7ae883d9e0cb3b34e40eec6db7ec53 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Tue, 9 Nov 2021 18:41:04 +0530
Subject: [PATCH 16/33] Poll timer
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 30abe6b..e19fc49 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,7 +1,7 @@
pipeline {
agent { label "master" }
- triggers { pollSCM 'H/5 * * * *' }
+ triggers { pollSCM '* * * * *' }
options {
skipDefaultCheckout true // Allows us to clean house before actual git pull
From 072985dc5e0fbee6b620d48573e5370ff492de10 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Thu, 11 Nov 2021 13:05:09 +0530
Subject: [PATCH 17/33] Updating the junit dependencies in the project objects
---
maven-unit-test/pom.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/maven-unit-test/pom.xml b/maven-unit-test/pom.xml
index 24d0188..7a62858 100644
--- a/maven-unit-test/pom.xml
+++ b/maven-unit-test/pom.xml
@@ -19,6 +19,7 @@
+
org.junit.jupiter
junit-jupiter-engine
From ca7b1084756e56715a8bc01832d4f2cc6654ebbc Mon Sep 17 00:00:00 2001
From: root
Date: Thu, 11 Nov 2021 08:50:55 +0000
Subject: [PATCH 18/33] Change the jUnit v5 to 6
---
maven-unit-test/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-unit-test/pom.xml b/maven-unit-test/pom.xml
index 7a62858..74e87bc 100644
--- a/maven-unit-test/pom.xml
+++ b/maven-unit-test/pom.xml
@@ -26,7 +26,7 @@
5.3.1
test
-
+
maven-unit-test
From fb2e7da34f5dbc2eb6f9065c9ecfea3d6940b5bf Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Thu, 11 Nov 2021 08:53:50 +0000
Subject: [PATCH 19/33] Added README Instructions
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 2b2354f..1b86c65 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,3 @@
-Source code for mkyong.com Apache Maven tutorial
https://www.mkyong.com/tutorials/maven-tutorials/
From 534e8d6b28b34954a8e6195f1b353ab53d7392fa Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Thu, 11 Nov 2021 14:24:15 +0530
Subject: [PATCH 20/33] Update the maven profiles
---
maven-profiles/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-profiles/pom.xml b/maven-profiles/pom.xml
index 15d4961..a09a4bd 100644
--- a/maven-profiles/pom.xml
+++ b/maven-profiles/pom.xml
@@ -8,7 +8,7 @@
maven-profiles
pom
1.0
-
+>
>
example1
From cb90fcef117a6749107e35a8f5fecf6d24c2754f Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Wed, 17 Nov 2021 10:37:17 +0000
Subject: [PATCH 21/33] Update the project object dependencies to v10
---
maven-unit-test/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-unit-test/pom.xml b/maven-unit-test/pom.xml
index 74e87bc..100fdcf 100644
--- a/maven-unit-test/pom.xml
+++ b/maven-unit-test/pom.xml
@@ -26,7 +26,7 @@
5.3.1
test
-
+
maven-unit-test
From 5491c02a815d133a248a52ab60475d725636cc6e Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Wed, 17 Nov 2021 10:37:50 +0000
Subject: [PATCH 22/33] Add extra notes to READMe.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1b86c65..35f2855 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,3 @@
-https://www.mkyong.com/tutorials/maven-tutorials/
+https://www.mkyong.com/tutorials/maven-tutorials
From 50226f672525b0be51d07a219719f4f062e578c5 Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Wed, 17 Nov 2021 15:46:54 +0000
Subject: [PATCH 23/33] Updated the groovy code to the Jenkinsfile
---
Jenkinsfile | 160 ++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 124 insertions(+), 36 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index e19fc49..c0ecc59 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,46 +1,134 @@
-pipeline {
- agent { label "master" }
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import hudson.tasks.test.AbstractTestResultAction;
+import hudson.model.Actionable;
- triggers { pollSCM '* * * * *' }
-
- options {
- skipDefaultCheckout true // Allows us to clean house before actual git pull
+
+def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-int') {
+ // build status of null means successful
+ buildStatus = buildStatus ?: 'SUCCESSFUL'
+
+
+ // buildStatus of null means successfull
+ buildStatus = buildStatus ?: 'SUCCESSFUL'
+ channel = channel ?: '#jenkins-ci-int'
+
+
+ // Default values
+ def colorName = 'RED'
+ def colorCode = '#FF0000'
+ def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}] (<${env.RUN_DISPLAY_URL}|Open>) (<${env.RUN_CHANGES_DISPLAY_URL}| Changes>)'"
+ def title = "${env.JOB_NAME} Build: ${env.BUILD_NUMBER}"
+ def title_link = "${env.RUN_DISPLAY_URL}"
+ def branchName = "${env.BRANCH_NAME}"
+
+ def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
+ def author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an'").trim()
+ def branch1 = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim()
+ def message = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
+
+ // Override default values based on build status
+ if (buildStatus == 'SUCCESSFUL') {
+ color = 'GREEN'
+ colorCode = 'good'
+ } else if (buildStatus == 'UNSTABLE') {
+ color = 'YELLOW'
+ colorCode = 'warning'
+ } else {
+ color = 'RED'
+ colorCode = 'danger'
+ }
+
+ // get test results for slack message
+ @NonCPS
+ def getTestSummary = {
+ def testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
+ def summary = ""
+
+ if (testResultAction != null) {
+ def total = testResultAction.totalCount
+ def failed = testResultAction.failCount
+ def skipped = testResultAction.skipCount
+
+ summary = "Test results:\n\t"
+ summary = summary + ("Passed: " + (total - failed - skipped))
+ summary = summary + (", Failed: " + failed + " ${testResultAction.failureDiffString}")
+ summary = summary + (", Skipped: " + skipped)
+ } else {
+ summary = "No tests found"
}
+ return summary
+ }
+ def testSummaryRaw = getTestSummary()
+ // format test summary as a code block
+ def testSummary = "```${testSummaryRaw}```"
+ println testSummary.toString()
- environment { // A good place to put high visibility/commit-changing variables
- SLACK_MESSAGE_CHANNEL = "slack-testing"
- SLACK_SUCCESS_COLOR = "#00FF00" // Green
- SLACK_UNSTABLE_COLOR = "#FFFF00" // Yellow
- SLACK_FAIL_COLOR = "#FF0000" // Red
- CONFIG_FILE_NAME = "config.xml"
+ JSONObject attachment = new JSONObject();
+ attachment.put('author',"jenkins");
+ attachment.put('author_link',"https://github.com/ziyanakthar");
+ attachment.put('title', title.toString());
+ attachment.put('title_link',title_link.toString());
+ attachment.put('text', subject.toString());
+ attachment.put('fallback', "fallback message");
+ attachment.put('color',colorCode);
+ attachment.put('mrkdwn_in', ["fields"])
+ // JSONObject for branch
+ JSONObject branch = new JSONObject();
+ branch.put('title', 'Branch');
+ branch.put('value', branch1.toString());
+ branch.put('short', true);
+ // JSONObject for author
+ JSONObject commitAuthor = new JSONObject();
+ commitAuthor.put('title', 'Author');
+ commitAuthor.put('value', author.toString());
+ commitAuthor.put('short', true);
+ // JSONObject for branch
+ JSONObject commitMessage = new JSONObject();
+ commitMessage.put('title', 'Commit Message');
+ commitMessage.put('value', message.toString());
+ commitMessage.put('short', false);
+ // JSONObject for test results
+ JSONObject testResults = new JSONObject();
+ testResults.put('title', 'Test Summary')
+ testResults.put('value', testSummary.toString())
+ testResults.put('short', false)
+ attachment.put('fields', [branch, commitAuthor, commitMessage, testResults]);
+ JSONArray attachments = new JSONArray();
+ attachments.add(attachment);
+ println attachments.toString()
+ println branch.toString()
+ println getGitBranchName()
+
+ // Send notifications
+ slackSend (color: colorCode, message: subject, attachments: attachments.toString(), channel: channel)
}
- stages {
- stage ("Initialization") {
- steps {
- cleanWs() // Clean house
- }
- }
- stage ("Maven Tests") {
- steps {
- sh 'git clone https://github.com/ziyanakthar/maven-examples.git && pwd && cd maven-examples/maven-unit-test && ls -ltr && mvn test && mvn install'
- }
-
-
- post {
- failure {
- slackSend (color: '#FF0000', message: """FAILED:
-Job: ${env.JOB_NAME}
-Build #${env.BUILD_NUMBER}
-Build: ${env.BUILD_URL}'""")
+def getGitBranchName() {
+ return scm.branches[0].name
+}
+
+node('master'){
+ stage ('Checkout') {
+ checkout([$class: 'GitSCM', branches: [[name: '*/release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
- success {
- slackSend (color: '#00FF00', message: """SUCCESS:
-Job: ${env.JOB_NAME}
-Build #${env.BUILD_NUMBER}
-Build: ${env.BUILD_URL}'""")
- }
+
+
+ stage ('Build') {
+ try {
+ // notifyBuild()
+
+ dir("./") {
+ sh 'pwd && ls -ltr && cd maven-unit-test && ls -ltr && mvn test && mvn install'
+ junit allowEmptyResults: true, keepLongStdio: true, skipMarkingBuildUnstable: true, skipPublishingChecks: true, testResults: '**/target/surefire-reports/*.xml'
}
+ } catch (e) {
+ // If there was an exception thrown, the build failed
+ currentBuild.result = "FAILED"
+ throw e
+ } finally {
+ // Success or failure, always send notifications
+ notifyBuild(currentBuild.result)
}
}
}
From b4461a10fd110dc9d5315146baa2f96a7fdcc239 Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Wed, 17 Nov 2021 15:50:36 +0000
Subject: [PATCH 24/33] Switching to develop branch
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index c0ecc59..121cfb2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -110,7 +110,7 @@ def getGitBranchName() {
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
From 2c685c89d6cf57cf9be54ecebcc79856f1cc9a9d Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 22:22:34 +0530
Subject: [PATCH 25/33] Update Jenkinsfile
---
Jenkinsfile | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 121cfb2..361bc42 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -24,7 +24,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
def author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an'").trim()
- def branch1 = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').trim()
+ def branch1 = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').tokenize('/')
def message = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
// Override default values based on build status
@@ -76,7 +76,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
// JSONObject for branch
JSONObject branch = new JSONObject();
branch.put('title', 'Branch');
- branch.put('value', branch1.toString());
+ branch.put('value', branch1[2]);
branch.put('short', true);
// JSONObject for author
JSONObject commitAuthor = new JSONObject();
@@ -98,22 +98,22 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
attachments.add(attachment);
println attachments.toString()
println branch.toString()
- println getGitBranchName()
+ println branch1[2]
+ //println getGitBranchName()
// Send notifications
slackSend (color: colorCode, message: subject, attachments: attachments.toString(), channel: channel)
}
-def getGitBranchName() {
- return scm.branches[0].name
-}
+//def getGitBranchName() {
+// return scm.branches[0].name
+//}
node('master'){
- stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ stage ('Checkout') {
+ checkout([$class: 'GitSCM', extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
-
-
+
stage ('Build') {
try {
// notifyBuild()
From 2499b0aff6b43605ff49500afab240e4ddc4021b Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 22:29:32 +0530
Subject: [PATCH 26/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 361bc42..b6bbfbe 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -111,7 +111,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
stage ('Build') {
From 3fb120553d2968df7db593aabda257a4198b0980 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 22:33:50 +0530
Subject: [PATCH 27/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index b6bbfbe..56547c1 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -111,7 +111,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '*/develop'], [name: '*/master'], [name: 'release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
stage ('Build') {
From 2cc748a336853ed7de5b524e8ef203b7561b41fe Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 22:34:05 +0530
Subject: [PATCH 28/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 56547c1..7df35eb 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -111,7 +111,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/develop'], [name: '*/master'], [name: 'release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '*/develop'], [name: '*/master'], [name: '*/release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
stage ('Build') {
From 2131beeec9bd51afb0d98d0ad0fa9406f44e5e21 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 23:16:03 +0530
Subject: [PATCH 29/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 7df35eb..1c571b2 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -111,7 +111,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/develop'], [name: '*/master'], [name: '*/release']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
stage ('Build') {
From 1155d518fa524e79446c4c36168e693cbb6cf265 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Wed, 17 Nov 2021 23:17:15 +0530
Subject: [PATCH 30/33] Update Jenkinsfile
---
Jenkinsfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Jenkinsfile b/Jenkinsfile
index 1c571b2..62d4e5f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -111,7 +111,7 @@ def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-in
node('master'){
stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
+ checkout([$class: 'GitSCM', branches: [[name: '*/']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
}
stage ('Build') {
From cf3e57f515b96d6ae849029d22de024ebcc79ec3 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Fri, 19 Nov 2021 12:48:44 +0530
Subject: [PATCH 31/33] Delete Jenkinsfile
---
Jenkinsfile | 134 ----------------------------------------------------
1 file changed, 134 deletions(-)
delete mode 100644 Jenkinsfile
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index 62d4e5f..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,134 +0,0 @@
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-import hudson.tasks.test.AbstractTestResultAction;
-import hudson.model.Actionable;
-
-
-def notifyBuild(String buildStatus = 'STARTED', String channel = '#jenkins-ci-int') {
- // build status of null means successful
- buildStatus = buildStatus ?: 'SUCCESSFUL'
-
-
- // buildStatus of null means successfull
- buildStatus = buildStatus ?: 'SUCCESSFUL'
- channel = channel ?: '#jenkins-ci-int'
-
-
- // Default values
- def colorName = 'RED'
- def colorCode = '#FF0000'
- def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}] (<${env.RUN_DISPLAY_URL}|Open>) (<${env.RUN_CHANGES_DISPLAY_URL}| Changes>)'"
- def title = "${env.JOB_NAME} Build: ${env.BUILD_NUMBER}"
- def title_link = "${env.RUN_DISPLAY_URL}"
- def branchName = "${env.BRANCH_NAME}"
-
- def commit = sh(returnStdout: true, script: 'git rev-parse HEAD')
- def author = sh(returnStdout: true, script: "git --no-pager show -s --format='%an'").trim()
- def branch1 = sh(returnStdout: true, script: 'git name-rev --name-only HEAD').tokenize('/')
- def message = sh(returnStdout: true, script: 'git log -1 --pretty=%B').trim()
-
- // Override default values based on build status
- if (buildStatus == 'SUCCESSFUL') {
- color = 'GREEN'
- colorCode = 'good'
- } else if (buildStatus == 'UNSTABLE') {
- color = 'YELLOW'
- colorCode = 'warning'
- } else {
- color = 'RED'
- colorCode = 'danger'
- }
-
- // get test results for slack message
- @NonCPS
- def getTestSummary = {
- def testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
- def summary = ""
-
- if (testResultAction != null) {
- def total = testResultAction.totalCount
- def failed = testResultAction.failCount
- def skipped = testResultAction.skipCount
-
- summary = "Test results:\n\t"
- summary = summary + ("Passed: " + (total - failed - skipped))
- summary = summary + (", Failed: " + failed + " ${testResultAction.failureDiffString}")
- summary = summary + (", Skipped: " + skipped)
- } else {
- summary = "No tests found"
- }
- return summary
- }
- def testSummaryRaw = getTestSummary()
- // format test summary as a code block
- def testSummary = "```${testSummaryRaw}```"
- println testSummary.toString()
-
- JSONObject attachment = new JSONObject();
- attachment.put('author',"jenkins");
- attachment.put('author_link',"https://github.com/ziyanakthar");
- attachment.put('title', title.toString());
- attachment.put('title_link',title_link.toString());
- attachment.put('text', subject.toString());
- attachment.put('fallback', "fallback message");
- attachment.put('color',colorCode);
- attachment.put('mrkdwn_in', ["fields"])
- // JSONObject for branch
- JSONObject branch = new JSONObject();
- branch.put('title', 'Branch');
- branch.put('value', branch1[2]);
- branch.put('short', true);
- // JSONObject for author
- JSONObject commitAuthor = new JSONObject();
- commitAuthor.put('title', 'Author');
- commitAuthor.put('value', author.toString());
- commitAuthor.put('short', true);
- // JSONObject for branch
- JSONObject commitMessage = new JSONObject();
- commitMessage.put('title', 'Commit Message');
- commitMessage.put('value', message.toString());
- commitMessage.put('short', false);
- // JSONObject for test results
- JSONObject testResults = new JSONObject();
- testResults.put('title', 'Test Summary')
- testResults.put('value', testSummary.toString())
- testResults.put('short', false)
- attachment.put('fields', [branch, commitAuthor, commitMessage, testResults]);
- JSONArray attachments = new JSONArray();
- attachments.add(attachment);
- println attachments.toString()
- println branch.toString()
- println branch1[2]
- //println getGitBranchName()
-
- // Send notifications
- slackSend (color: colorCode, message: subject, attachments: attachments.toString(), channel: channel)
- }
-
-//def getGitBranchName() {
-// return scm.branches[0].name
-//}
-
-node('master'){
- stage ('Checkout') {
- checkout([$class: 'GitSCM', branches: [[name: '*/']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/ziyanakthar/maven-examples.git']]])
- }
-
- stage ('Build') {
- try {
- // notifyBuild()
-
- dir("./") {
- sh 'pwd && ls -ltr && cd maven-unit-test && ls -ltr && mvn test && mvn install'
- junit allowEmptyResults: true, keepLongStdio: true, skipMarkingBuildUnstable: true, skipPublishingChecks: true, testResults: '**/target/surefire-reports/*.xml'
- }
- } catch (e) {
- // If there was an exception thrown, the build failed
- currentBuild.result = "FAILED"
- throw e
- } finally {
- // Success or failure, always send notifications
- notifyBuild(currentBuild.result)
- }
- }
-}
From 783bc5b65ddee15da81cb1572a6d7a19daab08c6 Mon Sep 17 00:00:00 2001
From: ziyanakthar <38223075+ziyanakthar@users.noreply.github.com>
Date: Fri, 19 Nov 2021 12:53:47 +0530
Subject: [PATCH 32/33] Updated License
---
LICENSE | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LICENSE b/LICENSE
index f0091f0..be79bd6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ sc Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
From 411bf3bdf05057bc5e63ae50ec709a45c059cdcd Mon Sep 17 00:00:00 2001
From: Jenkins CI
Date: Fri, 19 Nov 2021 07:27:19 +0000
Subject: [PATCH 33/33] Updated license with parameters
---
LICENSE | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LICENSE b/LICENSE
index be79bd6..4a64846 100644
--- a/LICENSE
+++ b/LICENSE
@@ -9,7 +9,7 @@
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
-
+SDDf
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to