diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 000000000..c8c9b0c99 --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,45 @@ +# 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: Build, Deploy, and Upload Artifacts + +on: + push: + branches: + - '**' + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + # 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' + + # 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 + + # 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-${{ github.run_number }}.war" 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/' + } + } + } +} 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 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' + } + } + } +} 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' + } + } + } +} 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' + } + } + } +} diff --git a/jenkinsfile4 b/jenkinsfile4 new file mode 100644 index 000000000..27d8bf151 --- /dev/null +++ b/jenkinsfile4 @@ -0,0 +1,16 @@ +pipeline { + agent { label 'dev' } + stages { + stage('Example') { + steps { + echo 'Hello World' + } + } + + stage('Example 2') { + steps { + echo 'Hello World 2' + } + } + } + } 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 +