From 4bc5db2de1f86f4507576ccac5207a2f08a0ac3e Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 7 Nov 2024 21:25:18 +0530 Subject: [PATCH 1/8] Add files via upload --- jenkins-maven-version.txt | 262 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 jenkins-maven-version.txt diff --git a/jenkins-maven-version.txt b/jenkins-maven-version.txt new file mode 100644 index 00000000..f3830ae2 --- /dev/null +++ b/jenkins-maven-version.txt @@ -0,0 +1,262 @@ +def currentBranch = env.BRANCH_NAME ?: "feature/devops" +def environmentNamespace = env.NAMESPACE ?: "dev" +def workspaceDirectory = "/home/jenkins/agent" +def versionFile = "devops/version.txt" + +pipeline { + agent { + kubernetes { + yaml """ +apiVersion: v1 +kind: Pod +spec: + serviceAccountName: jenkins + volumes: + - name: dockersock + hostPath: + path: /var/run/docker.sock + - name: varlibcontainers + emptyDir: {} + - name: jenkins-trusted-ca-bundle + configMap: + name: jenkins-trusted-ca-bundle + defaultMode: 420 + optional: true + - name: m2-cache + emptyDir: {} + containers: + - name: jnlp + securityContext: + privileged: true + envFrom: + - configMapRef: + name: jenkins-agent-env + optional: true + env: + - name: GIT_SSL_CAINFO + value: "/etc/pki/tls/certs/ca-bundle.crt" + volumeMounts: + - name: jenkins-trusted-ca-bundle + mountPath: /etc/pki/tls/certs + - name: cammismaven + image: 136299550619.dkr.ecr.us-west-2.amazonaws.com/cammismaven:1.0.0 + tty: true + command: ["/bin/bash"] + securityContext: + privileged: true + workingDir: /home/jenkins/agent + envFrom: + - configMapRef: + name: jenkins-agent-env + optional: true + env: + - name: HOME + value: /home/jenkins/agent + - name: BRANCH + value: ${currentBranch} + - name: NEXUS_ACCESS_TOKEN + valueFrom: + secretKeyRef: + name: jenkins-token-qqsb2 + key: token + - name: GIT_SSL_CAINFO + value: "/etc/pki/tls/certs/ca-bundle.crt" + volumeMounts: + - name: jenkins-trusted-ca-bundle + mountPath: /etc/pki/tls/certs + - name: m2-cache + mountPath: /root/.m2 + """ + } + } + + options { + disableConcurrentBuilds() + timeout(time: 5, unit: 'HOURS') + skipDefaultCheckout() + buildDiscarder(logRotator(numToKeepStr: '20')) + } + + parameters { + choice(name: 'RELEASE_TYPE', choices: ['PATCH', 'MINOR', 'MAJOR'], description: 'Enter Release type') + string(name: 'RELEASE', defaultValue: 'enter release name', description: 'Override Release Name') + } + + environment { + ... + } + + stages { + stage("Initialize") { + steps { + container('cammismaven') { + script { + deleteDir() + echo 'Checking out main source' + def mainCommit = checkout(scm).GIT_COMMIT + echo "Main repository commit ID: ${mainCommit}" + + // Load or initialize the version file + def version = "1.0.0" // Default version + if (fileExists(versionFile)) { + version = readFile(versionFile).trim() + } else { + writeFile(file: versionFile, text: version) + } + env.BUILD_VERSION = version + + // Compare with the previous build’s commit ID + if (fileExists('devops/previous_commit.txt')) { + def previousCommit = readFile('devops/previous_commit.txt').trim() + if (previousCommit == mainCommit) { + echo "No changes detected from previous build. Skipping build." + currentBuild.result = 'SUCCESS' + return + } + } + writeFile(file: 'devops/previous_commit.txt', text: mainCommit) + } + } + } + } + + stage("Versioning") { + steps { + container('cammismaven') { + script { + // Determine version increment based on RELEASE_TYPE + def (major, minor, patch) = env.BUILD_VERSION.tokenize('.') + if (params.RELEASE_TYPE == 'MAJOR') { + major = major.toInteger() + 1 + minor = 0 + patch = 0 + } else if (params.RELEASE_TYPE == 'MINOR') { + minor = minor.toInteger() + 1 + patch = 0 + } else { + patch = patch.toInteger() + 1 + } + env.BUILD_VERSION = "${major}.${minor}.${patch}" + writeFile(file: versionFile, text: env.BUILD_VERSION) + + echo "Updated version to ${env.BUILD_VERSION}" + } + } + } + } + + stage("Build") { + steps { + container('cammismaven') { + script { + echo 'Building SURGE_common project' + dir('SURGE_common') { + sh 'mvn clean install' + } + + echo 'Building and packaging SURGE_image_viewer project' + dir('SURGE_image_viewer/SURGE_image_viewer') { + sh "mvn clean package -Dproject.version=${env.BUILD_VERSION} --settings ${MAVEN_CONFIG_DIR}/settings.xml" + } + } + } + } + } + + stage('Sonar Scan') { + steps { + script { + withSonarQubeEnv('sonar_server') { + container(name: "cammismaven") { + sh """ + echo 'wget and unzip file' + mkdir -p /home/jenkins/agent/.sonar/native-sonar-scanner + wget --quiet https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip + unzip -q sonar-scanner-cli-6.1.0.4477-linux-x64.zip -d /home/jenkins/agent/.sonar/native-sonar-scanner + """ + } + container(name: "jnlp") { + sh """ + echo 'doing sonar-scanner call' + /home/jenkins/agent/.sonar/native-sonar-scanner/sonar-scanner-6.1.0.4477-linux-x64/bin/sonar-scanner -Dproject.settings=${WORKSPACE}/SURGE_image_viewer/devops/sonar/sonar-project.properties + """ + } + } + } + } + } + + stage("Quality Gate") { + steps { + container(name: "jnlp") { + script { + sh """ + echo "######################################################################################\n" + echo "#### RUNNING SONARQUBE QUALITY GATE CHECK ####\n" + echo "SONAR TIMEOUT ${SONAR_TIMEOUT}" + cat ${WORKSPACE}/SURGE_image_viewer/devops/sonar/sonar-project.properties + echo "#################################################################################\n" + """ + sleep time: SONAR_SLEEP, unit: "MILLISECONDS" + + timeout(time: SONAR_TIMEOUT, unit: 'MINUTES') { + def qualGate = waitForQualityGate() + if (qualGate.status == "OK") { + echo "PIPELINE INFO: ${qualGate.status}\n" + } else if (qualGate.status == "NONE") { + SONAR_SLACK_MSG = "PIPELINE WARNING: NO Quality Gate or projectKey associated with project \nCheck sonar-project.properties projectKey value is correct" + echo "Quality gate failure: ${qualGate.status} \n ${SONAR_SLACK_MSG} \n#####################################################################################################################\n" + currentBuild.result = SONAR_BUILD_RESULT + } else { + echo "Quality Gate: ${qualGate.status} \n ${SONAR_SLACK_MSG} \n#####################################################################################################################\n" + slackNotification("pipeline","${APP_NAME}-${env_git_branch_name}: <${BUILD_URL}|build #${BUILD_NUMBER}> ${SONAR_SLACK_MSG}.", "#F6F60F","true") + currentBuild.result = SONAR_BUILD_RESULT + } + } + } + } + } + } + + stage('prepare deployment') { + steps { + container('cammismaven') { + script { + sh ''' + cd SURGE_image_viewer/SURGE_image_viewer + FILENAME=$(ls target/ | grep -E '.jar$|.war$|.ear$' | head -1) + FILETYPE="${FILENAME##*.}" + curl -kv -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} -F "maven2.generate-pom=false" -F "maven2.asset1=@pom.xml" -F "maven2.asset1.extension=pom" -F "maven2.asset2=@target/$FILENAME;type=application/java-archive" -F "maven2.asset2.extension=$FILETYPE" ${NEXUS_URL}/service/rest/v1/components?repository=${NEXUS_REPOSITORY} + ''' + + } + } + } + } + stage("Push to GitHub") { + steps { + container('cammismaven') { + script { + // Configure Git with user details if needed + sh """ + git config user.name "Jenkins CI" + git config user.email "jenkins@example.com" + """ + + // Check for changes in version.txt and previous_commit.txt + sh """ + git add ${versionFile} previous_commit.txt + if ! git diff --cached --quiet; then + git commit -m "Update version to ${env.BUILD_VERSION} and record commit ID" + git push origin ${currentBranch} + else + echo "No changes to push." + fi + """ + } + } + } +} + +} +} From 56993ac29b5f912133619ede69bcc78e93494ed0 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:40:44 +0530 Subject: [PATCH 2/8] Add files via upload --- nexus-cicd-version.groovy | 380 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 380 insertions(+) create mode 100644 nexus-cicd-version.groovy diff --git a/nexus-cicd-version.groovy b/nexus-cicd-version.groovy new file mode 100644 index 00000000..5e66d984 --- /dev/null +++ b/nexus-cicd-version.groovy @@ -0,0 +1,380 @@ +def currentBranch = env.BRANCH_NAME ?: 'feature/devops' +def environmentNamespace = env.NAMESPACE ?: 'dev' +def workspaceDirectory = '/home/jenkins/agent' +def versionFile = "devops/version.txt" + +pipeline { + agent { + kubernetes { + yaml """ +apiVersion: v1 +kind: Pod +spec: + serviceAccountName: jenkins + volumes: + - name: dockersock + hostPath: + path: /var/run/docker.sock + - name: varlibcontainers + emptyDir: {} + - name: jenkins-trusted-ca-bundle + configMap: + name: jenkins-trusted-ca-bundle + defaultMode: 420 + optional: true + - name: m2-cache + emptyDir: {} + containers: + - name: jnlp + securityContext: + privileged: true + envFrom: + - configMapRef: + name: jenkins-agent-env + optional: true + env: + - name: GIT_SSL_CAINFO + value: "/etc/pki/tls/certs/ca-bundle.crt" + volumeMounts: + - name: jenkins-trusted-ca-bundle + mountPath: /etc/pki/tls/certs + - name: cammismaven + image: 136299550619.dkr.ecr.us-west-2.amazonaws.com/cammismaven:1.0.0 + tty: true + command: ["/bin/bash"] + securityContext: + privileged: true + workingDir: /home/jenkins/agent + envFrom: + - configMapRef: + name: jenkins-agent-env + optional: true + env: + - name: HOME + value: /home/jenkins/agent + - name: BRANCH + value: ${currentBranch} + - name: NEXUS_ACCESS_TOKEN + valueFrom: + secretKeyRef: + name: jenkins-token-qqsb2 + key: token + - name: GIT_SSL_CAINFO + value: "/etc/pki/tls/certs/ca-bundle.crt" + volumeMounts: + - name: jenkins-trusted-ca-bundle + mountPath: /etc/pki/tls/certs + - name: m2-cache + mountPath: /root/.m2 + """ + } + } + + options { + disableConcurrentBuilds() + timeout(time: 5, unit: 'HOURS') + skipDefaultCheckout() + buildDiscarder(logRotator(numToKeepStr: '20')) + } + parameters { + choice(name: 'RELEASE_TYPE', choices: ['PATCH', 'MINOR', 'MAJOR'], description: 'Enter Release type') + booleanParam(name: 'DEPLOY_TO_CURRENT', defaultValue: false, description: 'Deploy then current build ?') + booleanParam(name: 'DEPLOY_TO_PREVIOUS', defaultValue: true, description: 'Deploy to Previous build Version?') + extendedChoice( + name: 'ARTIFACT_VERSION', + description: 'Choose the artifact version from Nexus', + type: 'PT_SINGLE_SELECT', + groovyScript: ''' + def nexusUrl = "https://nexusrepo-tools.apps.bld.cammis.medi-cal.ca.gov/service/rest/v1/search?repository=maven-releases&group=tarpurge&name=tarpurge" + def versions = [] + def jsonSlurper = new groovy.json.JsonSlurper() + def response = new URL(nexusUrl).text + def parsedResponse = jsonSlurper.parseText(response) + + parsedResponse.items.each { item -> + versions.add(item.version) + } + return versions.reverse() + ''', + multiSelectDelimiter: ',' + ) + } + + environment { + env_git_branch_type = 'feature/devops' + env_git_branch_name = '' + env_current_git_commit = '' + env_skip_build = 'false' + env_stage_name = '' + env_step_name = '' + env_release_type = "${params.RELEASE_TYPE}" + + SONAR_TIMEOUT = 3 + SONAR_SLEEP = 10000 + SONAR_ERROR_MSG = 'QUALITY GATE ERROR: Pipeline set to unstable ' + SONAR_BUILD_RESULT = 'UNSTABLE' + SONAR_SLACK_MSG = 'Quality Gate Passed' + + NEXUS_URL = 'https://nexusrepo-tools.apps.bld.cammis.medi-cal.ca.gov' + NEXUS_REPOSITORY = 'feature-image-viewer-app' + NEXUS_CREDENTIALS = credentials('nexus-credentials') + MAVEN_CONFIG_DIR = '/root/.m2' // Define the Maven configuration directory + COMMON_REPO = 'https://github.com/ca-mmis/tar-common.git' + IMAGE_VIEWER_REPO = 'https://github.com/ca-mmis/tar-image-viewer-app.git' + GIT_CREDENTIALS = 'github-key' + REPOSITORY = 'feature-image-viewer-app' + GROUP_ID = 'SURGE_image_viewer' + ARTIFACT_ID = 'SURGE_image_viewer' + PACKAGING = 'war' + CREDENTIALS_ID = 'nexus-credentials' + } + + stages { + stage('Initialize') { + steps { + container('cammismaven') { + script { + deleteDir() + echo 'Checkout main source and get the commit ID' + def mainCommit = checkout(scm).GIT_COMMIT + echo "Main repository commit ID: ${mainCommit}" + + // Load or initialize the version file + def version = "1.0.0" // Default version + if (fileExists(versionFile)) { + version = readFile(versionFile).trim() + } else { + writeFile(file: versionFile, text: version) + } + env.BUILD_VERSION = version + + // Compare with the previous build’s commit ID + if (fileExists('devops/previous_commit.txt')) { + def previousCommit = readFile('devops/previous_commit.txt').trim() + if (previousCommit == mainCommit) { + echo "No changes detected from previous build. Skipping build." + currentBuild.result = 'SUCCESS' + return + } + } + writeFile(file: 'devops/previous_commit.txt', text: mainCommit) + + echo 'Cloning SURGE_common and tar_image_viewer repositories' + git branch: 'master', credentialsId: GIT_CREDENTIALS, url: COMMON_REPO + dir('SURGE_image_viewer') { + git branch: 'feature/devops', credentialsId: GIT_CREDENTIALS, url: IMAGE_VIEWER_REPO + } + + echo 'Creating Maven settings.xml' + sh """ + mkdir -p ${MAVEN_CONFIG_DIR} + echo " + ${MAVEN_CONFIG_DIR}/repository + " > ${MAVEN_CONFIG_DIR}/settings.xml + """ + } + } + } + } + stage("Versioning") { + steps { + container('cammismaven') { + script { + // Determine version increment based on RELEASE_TYPE + def (major, minor, patch) = env.BUILD_VERSION.tokenize('.') + if (params.RELEASE_TYPE == 'MAJOR') { + major = major.toInteger() + 1 + minor = 0 + patch = 0 + } else if (params.RELEASE_TYPE == 'MINOR') { + minor = minor.toInteger() + 1 + patch = 0 + } else { + patch = patch.toInteger() + 1 + } + env.BUILD_VERSION = "${major}.${minor}.${patch}" + writeFile(file: versionFile, text: env.BUILD_VERSION) + + echo "Updated version to ${env.BUILD_VERSION}" + } + } + } + } + stage('Build') { + steps { + container('cammismaven') { + script { + echo 'Building SURGE_common project' + dir('SURGE_common') { + sh 'mvn clean install' + } + + echo 'Building and packaging SURGE_image_viewer project' + dir('SURGE_image_viewer/SURGE_image_viewer') { + sh "mvn clean package --settings ${MAVEN_CONFIG_DIR}/settings.xml" + } + } + } + } + } + + stage('Sonar Scan') { + steps { + script { + withSonarQubeEnv('sonar_server') { + container(name: 'cammismaven') { + sh """ + echo 'wget and unzip file' + mkdir -p /home/jenkins/agent/.sonar/native-sonar-scanner + wget --quiet https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip + unzip -q sonar-scanner-cli-6.1.0.4477-linux-x64.zip -d /home/jenkins/agent/.sonar/native-sonar-scanner + """ + } + container(name: 'jnlp') { + sh """ + echo 'doing sonar-scanner call' + /home/jenkins/agent/.sonar/native-sonar-scanner/sonar-scanner-6.1.0.4477-linux-x64/bin/sonar-scanner -Dproject.settings=${WORKSPACE}/SURGE_image_viewer/devops/sonar/sonar-project.properties + """ + } + } + } + } + } + + stage('Quality Gate') { + steps { + container(name: 'jnlp') { + script { + sh """ + echo "######################################################################################\n" + echo "#### RUNNING SONARQUBE QUALITY GATE CHECK ####\n" + echo "SONAR TIMEOUT ${SONAR_TIMEOUT}" + cat ${WORKSPACE}/SURGE_image_viewer/devops/sonar/sonar-project.properties + echo "#################################################################################\n" + """ + sleep time: SONAR_SLEEP, unit: 'MILLISECONDS' + + timeout(time: SONAR_TIMEOUT, unit: 'MINUTES') { + def qualGate = waitForQualityGate() + if (qualGate.status == 'OK') { + echo "PIPELINE INFO: ${qualGate.status}\n" + } else if (qualGate.status == 'NONE') { + SONAR_SLACK_MSG = 'PIPELINE WARNING: NO Quality Gate or projectKey associated with project \nCheck sonar-project.properties projectKey value is correct' + echo "Quality gate failure: ${qualGate.status} \n ${SONAR_SLACK_MSG} \n#####################################################################################################################\n" + currentBuild.result = SONAR_BUILD_RESULT + } else { + echo "Quality Gate: ${qualGate.status} \n ${SONAR_SLACK_MSG} \n#####################################################################################################################\n" + slackNotification('pipeline', "${APP_NAME}-${env_git_branch_name}: <${BUILD_URL}|build #${BUILD_NUMBER}> ${SONAR_SLACK_MSG}.", '#F6F60F', 'true') + currentBuild.result = SONAR_BUILD_RESULT + } + } + } + } + } + } + + stage('Nexus Upload') { + steps { + container('cammismaven') { + script { + sh ''' + cd SURGE_image_viewer/SURGE_image_viewer + FILENAME=$(ls target/ | grep -E '.jar$|.war$|.ear$' | head -1) + FILETYPE="${FILENAME##*.}" + curl -kv -u ${NEXUS_CREDENTIALS_USR}:${NEXUS_CREDENTIALS_PSW} -F "maven2.generate-pom=false" -F "maven2.asset1=@pom.xml" -F "maven2.asset1.extension=pom" -F "maven2.asset2=@target/$FILENAME;type=application/java-archive" -F "maven2.asset2.extension=$FILETYPE" ${NEXUS_URL}/service/rest/v1/components?repository=${NEXUS_REPOSITORY} + ''' + } + } + } + } + stage("Push to GitHub") { + steps { + container('cammismaven') { + script { + // Configure Git with user details if needed + sh """ + git config user.name "Jenkins CI" + git config user.email "jenkins@example.com" + """ + + // Check for changes in version.txt and previous_commit.txt + sh """ + git add ${versionFile} previous_commit.txt + if ! git diff --cached --quiet; then + git commit -m "Update version to ${env.BUILD_VERSION} and record commit ID" + git push origin ${currentBranch} + else + echo "No changes to push." + fi + """ + } + } + stage('Deploy to server') { + when { + expression { params.DEPLOY_TO_CURRENT == 'true' } + } + steps { + container('cammismaven') { + script { + + sh ''' + echo " deploying latest version to tomcat" + ''' + + } + } + } + } + stage('Download and Deploy to server') { + when { + expression { params.DEPLOY_TO_PREVIOUS == 'true' } + } + steps { + container('cammismaven') { + script { + + def selectedVersion = params.ARTIFACT_VERSION + def targetDirectory = "${workspaceDirectory}/target" + + // Prepare download URLs for each file type + def jarDownloadUrl = "${NEXUS_URL}/repository/${NEXUS_REPOSITORY}/${GROUP_ID.replace('.', '/')}/${ARTIFACT_ID}/${selectedVersion}/${ARTIFACT_ID}-${selectedVersion}.war" + withCredentials([usernamePassword(credentialsId: 'nexus-credentials', usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASS')]) { + // Download JAR file + sh """ + curl -o ${targetDirectory}/${ARTIFACT_ID}-${selectedVersion}.jar -u '${NEXUS_USER}:${NEXUS_PASS}' -k "${jarDownloadUrl}" + """ + } + + } + } + } + } + stage("Push to GitHub") { + when { + expression { params.DEPLOY_TO_CURRENT == 'true' } + } + steps { + container('cammismaven') { + script { + // Configure Git with user details if needed + sh """ + git config user.name "Jenkins" + git config user.email "jenkins@cammis.com" + """ + + // Check for changes in version.txt and previous_commit.txt + sh """ + git add ${versionFile} previous_commit.txt + if ! git diff --cached --quiet; then + git commit -m "Update version to ${env.BUILD_VERSION} and record commit ID" + git push origin ${currentBranch} + else + echo "No changes to push." + fi + """ + } + } + } From aa8ed87f5bded4a7e5b40568ca0bdf5a0e1ba989 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 08:51:04 +0530 Subject: [PATCH 3/8] Add Jenkins pipeline for building Java application --- Jenkinsfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..b12263e1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent any + + tools { + // Install the Maven version configured as "M3" and add it to the path. + maven "maven" + } + + stages { + stage('Build') { + steps { + // Get some code from a GitHub repository + git branch: 'main', url: 'https://github.com/malleshdevops/sample-java-app.git' + + // Run Maven on a Unix agent. + sh "mvn -Dmaven.test.failure.ignore=true clean package" + + // To run Maven on a Windows agent, use + // bat "mvn -Dmaven.test.failure.ignore=true clean package" + } + } + } +} From c8ebb5a6f4add8e17b685e037d3ed7465e34abd8 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 08:57:26 +0530 Subject: [PATCH 4/8] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b12263e1..0461b2a6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Build') { steps { // Get some code from a GitHub repository - git branch: 'main', url: 'https://github.com/malleshdevops/sample-java-app.git' + // git branch: 'main', url: 'https://github.com/malleshdevops/sample-java-app.git' // Run Maven on a Unix agent. sh "mvn -Dmaven.test.failure.ignore=true clean package" From 82ea0ed65776bc26cda8029dc866ece26e431597 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 09:06:44 +0530 Subject: [PATCH 5/8] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0461b2a6..01105836 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { agent any - + options { buildDiscarder(logRotator(numToKeepStr: '10')) } tools { // Install the Maven version configured as "M3" and add it to the path. maven "maven" From 91f61ebc33af685e13faf640309511e2ddfe57e1 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 09:09:23 +0530 Subject: [PATCH 6/8] Update Jenkinsfile --- Jenkinsfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 01105836..bb72ffac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,9 @@ pipeline { agent any - options { buildDiscarder(logRotator(numToKeepStr: '10')) } + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + timestamps() + } tools { // Install the Maven version configured as "M3" and add it to the path. maven "maven" From 7881113b3d37626434bf6937f9f13ae741aa27f0 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 09:14:29 +0530 Subject: [PATCH 7/8] Update Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index bb72ffac..3326bb82 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ pipeline { buildDiscarder(logRotator(numToKeepStr: '10')) timestamps() } + triggers { + cron('*/2 * * * *') + } tools { // Install the Maven version configured as "M3" and add it to the path. maven "maven" From 76792f8c7216dc8f9ba39f6e7a79ce3014eac2c5 Mon Sep 17 00:00:00 2001 From: malleshdevops <81004732+malleshdevops@users.noreply.github.com> Date: Thu, 2 Apr 2026 09:26:15 +0530 Subject: [PATCH 8/8] Update Jenkinsfile --- Jenkinsfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3326bb82..477d6a34 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,17 @@ pipeline { // Install the Maven version configured as "M3" and add it to the path. maven "maven" } + parameters { + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') + + text(name: 'BIOGRAPHY', defaultValue: '', description: 'Enter some information about the person') + + booleanParam(name: 'TOGGLE', defaultValue: true, description: 'Toggle this value') + + choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something') + + password(name: 'PASSWORD', defaultValue: 'SECRET', description: 'Enter a password') + } stages { stage('Build') { @@ -25,5 +36,17 @@ pipeline { // bat "mvn -Dmaven.test.failure.ignore=true clean package" } } + stage("parameters"){ + steps { + echo "Hello ${params.PERSON}" + echo "Biography: ${params.BIOGRAPHY}" + + echo "Toggle: ${params.TOGGLE}" + + echo "Choice: ${params.CHOICE}" + + echo "Password: ${params.PASSWORD}" + } + } } }