From 1be051be433adbce4a84df64c0c83ce5ce694237 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 07:44:29 +0530 Subject: [PATCH 01/20] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 85f2e2e2a..3163a7df1 100644 --- a/pom.xml +++ b/pom.xml @@ -21,9 +21,9 @@ org.apache.maven.plugins maven-war-plugin - 2.1.1 + 3.4.0 - \ No newline at end of file + From 50bd93ff771922e500587d083696016e32088c8e Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 08:06:25 +0530 Subject: [PATCH 02/20] Create build.sh --- build.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 000000000..8fac700fa --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +ls +rm -rf * +git clone https://github.com/hhgsharish/hello-world-war.git +cd hello-world-war +mvn clean package From d2baba140f3e50e03e33a1fe55e5f36455fdf8ab Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 09:05:32 +0530 Subject: [PATCH 03/20] Update build.sh --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index 8fac700fa..c32035736 100644 --- a/build.sh +++ b/build.sh @@ -3,3 +3,4 @@ rm -rf * git clone https://github.com/hhgsharish/hello-world-war.git cd hello-world-war mvn clean package +edit test From 528e9181382cdfa535363962d501e0d8204563bf Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 17:55:47 +0530 Subject: [PATCH 04/20] Create maven-publish.yml --- .github/workflows/maven-publish.yml | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 000000000..64b848b61 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,34 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path + +name: Maven Package + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Publish to GitHub Packages Apache Maven + run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml + env: + GITHUB_TOKEN: ${{ github.token }} From ad0154f6a532620d10a52748def822c1d82c17b3 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 18:06:11 +0530 Subject: [PATCH 05/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 51 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 64b848b61..4c05543e7 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -1,34 +1,41 @@ # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path -name: Maven Package +name: Build, Deploy, and Upload Artifacts on: - release: - types: [created] + push: + branches: + - '**' + pull_request: + branches: + - master + workflow_dispatch: jobs: build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - java-version: '11' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file + # Checkout the repository + - name: Checkout Code + uses: actions/checkout@v3 + + # Set up Java + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' - - name: Build with Maven - run: mvn -B package --file pom.xml + # Cache Maven dependencies + - name: Cache Maven dependencies + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: + + # Build the project with Maven + - name: Build with Maven + run: mvn clean install - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml - env: - GITHUB_TOKEN: ${{ github.token }} From a0d4c27a664609f6dae3fcc8f70d487b099ac11e Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 18:13:04 +0530 Subject: [PATCH 06/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 4c05543e7..3a0359d6e 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -39,3 +39,9 @@ jobs: - name: Build with Maven run: mvn clean install + # Upload the WAR as an artifact using v4 + - name: Upload WAR as artifact + uses: actions/upload-artifact@v4 + with: + name: my-app-war + path: target/hello-world-war-1.0.0.war From eb7fc079104e0f1484bc6749504cc1af7343e716 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 18:20:05 +0530 Subject: [PATCH 07/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 3a0359d6e..378790d94 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -14,7 +14,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted steps: # Checkout the repository - name: Checkout Code From fabe1aa8013c73c17e67316ab9adb84187dfcf2d Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 18:58:45 +0530 Subject: [PATCH 08/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 378790d94..f1d8b1bfc 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -14,7 +14,7 @@ on: jobs: build: - runs-on: self-hosted + runs-on: ubuntu-latest steps: # Checkout the repository - name: Checkout Code @@ -40,8 +40,6 @@ jobs: run: mvn clean install # Upload the WAR as an artifact using v4 - - name: Upload WAR as artifact - uses: actions/upload-artifact@v4 - with: - name: my-app-war - path: target/hello-world-war-1.0.0.war + - name: Upload WAR file to Artifactory + run: | + curl -u "hhgsharish@gmail.com:cmVmdGtuOjAxOjE3NjcwMTQxOTg6MkpGS3RiQVhxMEhYNkRHbURxNWR5UWlHY2lR" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" From 55e86d928c1f4220151003b353083124518d3664 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 18:59:38 +0530 Subject: [PATCH 09/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index f1d8b1bfc..aea10c466 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -42,4 +42,4 @@ jobs: # Upload the WAR as an artifact using v4 - name: Upload WAR file to Artifactory run: | - curl -u "hhgsharish@gmail.com:cmVmdGtuOjAxOjE3NjcwMTQxOTg6MkpGS3RiQVhxMEhYNkRHbURxNWR5UWlHY2lR" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" + curl -u "hhgsharish@gmail.com:cmVmdGtuOjAxOjE3NjcwMTQxOTg6MkpGS3RiQVhxMEhYNkRHbURxNWR5UWlHY2lR" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" From f6c56f9b0503e87ce15c4e9e97e74fad8b0fd81a Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 19:08:02 +0530 Subject: [PATCH 10/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index aea10c466..9d3709334 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -42,4 +42,4 @@ jobs: # Upload the WAR as an artifact using v4 - name: Upload WAR file to Artifactory run: | - curl -u "hhgsharish@gmail.com:cmVmdGtuOjAxOjE3NjcwMTQxOTg6MkpGS3RiQVhxMEhYNkRHbURxNWR5UWlHY2lR" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" + curl -u "${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_API_KEY }}" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" From 5cf9261113fa23d33170d963d7004a4610abfbe1 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 19:10:47 +0530 Subject: [PATCH 11/20] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 9d3709334..c8c9b0c99 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -42,4 +42,4 @@ jobs: # Upload the WAR as an artifact using v4 - name: Upload WAR file to Artifactory run: | - curl -u "${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_API_KEY }}" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war.war" + curl -u "${{ secrets.ARTIFACTORY_USERNAME }}:${{ secrets.ARTIFACTORY_API_KEY }}" -T "target/hello-world-war-1.0.0.war" "https://trialvvjw1c.jfrog.io/artifactory/my-hello-world-new-libs-snapshot/com/jfrog/my-jfrog-app/hello-world-war-${{ github.run_number }}.war" From 18890ad2f1f91ca149ebfe532f325bc6a8bc9c68 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Sun, 29 Dec 2024 19:12:16 +0530 Subject: [PATCH 12/20] Update build.sh --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index c32035736..3a2501469 100644 --- a/build.sh +++ b/build.sh @@ -3,4 +3,4 @@ rm -rf * git clone https://github.com/hhgsharish/hello-world-war.git cd hello-world-war mvn clean package -edit test +edit From 25fed6a01474cb3bfb4278763e73aa369c335af9 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Mon, 30 Dec 2024 22:22:52 +0530 Subject: [PATCH 13/20] Update build.sh --- build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sh b/build.sh index 3a2501469..8fac700fa 100644 --- a/build.sh +++ b/build.sh @@ -3,4 +3,3 @@ rm -rf * git clone https://github.com/hhgsharish/hello-world-war.git cd hello-world-war mvn clean package -edit From bd605ebc482cb95d6ca52806e3b0a0c60948df6c Mon Sep 17 00:00:00 2001 From: Harisha G Date: Tue, 31 Dec 2024 21:26:05 +0530 Subject: [PATCH 14/20] Create jenkinsfile --- jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 jenkinsfile diff --git a/jenkinsfile b/jenkinsfile new file mode 100644 index 000000000..83d621b6d --- /dev/null +++ b/jenkinsfile @@ -0,0 +1,16 @@ +pipeline { + agent any + stages + { + stage('test') { + steps { + echo 'Hello World' + } + } + stage('sample') { + steps { + echo 'Welcome to devops' + } + } + } +} From 83af8d915908d9b6211cef82e7898d9e0c4ea927 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Wed, 1 Jan 2025 23:19:25 +0530 Subject: [PATCH 15/20] Create jenkinsfile2 --- jenkinsfile2 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 jenkinsfile2 diff --git a/jenkinsfile2 b/jenkinsfile2 new file mode 100644 index 000000000..b23bdcfed --- /dev/null +++ b/jenkinsfile2 @@ -0,0 +1,17 @@ +pipeline { + agent any + stages + { + stage('checkout') { + steps { + sh 'git clone https://github.com/hhgsharish/hello-world-war/' + } + } + stage('build') { + steps { + sh 'cd hello-world-war' + sh 'mvn clean package' + } + } + } +} From 2f1ed3db132c7242b60b8b747c34fb30aff9dcd8 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Wed, 1 Jan 2025 23:22:57 +0530 Subject: [PATCH 16/20] Create jenkinsfile3 --- jenkinsfile3 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 jenkinsfile3 diff --git a/jenkinsfile3 b/jenkinsfile3 new file mode 100644 index 000000000..f70f52c5a --- /dev/null +++ b/jenkinsfile3 @@ -0,0 +1,23 @@ +pipeline { + parameters { + string(name: 'cmd', defaultValue: 'package', description: 'Who should I say hello to?') + + choice(name: 'Choice', choices: ['One', 'Two', 'Three'], description: 'Pick something') + } + agent any + stages + { + stage('checkout') { + steps { + sh 'rm -rf hello-world-war' + sh 'git clone https://github.com/sharanya123-ty/hello-world-war/' + } + } + stage('build') { + steps { + sh 'cd hello-world-war' + sh 'mvn clean $cmd' + } + } + } +} From a0a22dfdd9da8eb8dd524769b7fdce7734d48179 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Thu, 2 Jan 2025 20:09:35 +0530 Subject: [PATCH 17/20] Create jenkinsfile4 --- jenkinsfile4 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 jenkinsfile4 diff --git a/jenkinsfile4 b/jenkinsfile4 new file mode 100644 index 000000000..5e6aad521 --- /dev/null +++ b/jenkinsfile4 @@ -0,0 +1,16 @@ +pipeline { + agent { label 'dev' } + stages { + stage('Example') { + steps { + echo 'Hello World' + } + } + stages { + stage('Example 2') { + steps { + echo 'Hello World 2' + } + } + } + } From 8836be7b983aa0db8637394b3f5a907fb5578918 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Thu, 2 Jan 2025 20:13:04 +0530 Subject: [PATCH 18/20] Update jenkinsfile4 --- jenkinsfile4 | 1 + 1 file changed, 1 insertion(+) diff --git a/jenkinsfile4 b/jenkinsfile4 index 5e6aad521..efc36875f 100644 --- a/jenkinsfile4 +++ b/jenkinsfile4 @@ -6,6 +6,7 @@ pipeline { echo 'Hello World' } } + } stages { stage('Example 2') { steps { From e2441ab96ed22f7efcad888fbb565641590eb622 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Thu, 2 Jan 2025 20:15:02 +0530 Subject: [PATCH 19/20] Update jenkinsfile4 --- jenkinsfile4 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jenkinsfile4 b/jenkinsfile4 index efc36875f..27d8bf151 100644 --- a/jenkinsfile4 +++ b/jenkinsfile4 @@ -6,8 +6,7 @@ pipeline { echo 'Hello World' } } - } - stages { + stage('Example 2') { steps { echo 'Hello World 2' From 3d72140d94b03ef223f25b8217c4cf8d9a571118 Mon Sep 17 00:00:00 2001 From: Harisha G Date: Thu, 2 Jan 2025 23:11:20 +0530 Subject: [PATCH 20/20] Create Jenkinsfile5 --- Jenkinsfile5 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Jenkinsfile5 diff --git a/Jenkinsfile5 b/Jenkinsfile5 new file mode 100644 index 000000000..18917bd9a --- /dev/null +++ b/Jenkinsfile5 @@ -0,0 +1,21 @@ +pipeline { + agent { label 'dev' } + stages { + stage('checkout') { + steps { + sh " rm -rf hello-world-war " + sh "git clone https://github.com/hhgsharish/hello-world-war.git" + } + } + stage('build') { + steps { + sh "mvn clean package" + } + } + stage('deploy') { + steps { + sh 'sudo scp /opt/jenkins/workspace/assign_pipeline/target/hello-world-war-1.0.0.war root@172.31.13.101:/opt/tomcat/webapps/' + } + } + } +}