Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -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"
21 changes: 21 additions & 0 deletions Jenkinsfile5
Original file line number Diff line number Diff line change
@@ -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/'
}
}
}
}
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ls
rm -rf *
git clone https://github.com/hhgsharish/hello-world-war.git
cd hello-world-war
mvn clean package
16 changes: 16 additions & 0 deletions jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipeline {
agent any
stages
{
stage('test') {
steps {
echo 'Hello World'
}
}
stage('sample') {
steps {
echo 'Welcome to devops'
}
}
}
}
17 changes: 17 additions & 0 deletions jenkinsfile2
Original file line number Diff line number Diff line change
@@ -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'
}
}
}
}
23 changes: 23 additions & 0 deletions jenkinsfile3
Original file line number Diff line number Diff line change
@@ -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'
}
}
}
}
16 changes: 16 additions & 0 deletions jenkinsfile4
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipeline {
agent { label 'dev' }
stages {
stage('Example') {
steps {
echo 'Hello World'
}
}

stage('Example 2') {
steps {
echo 'Hello World 2'
}
}
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<version>3.4.0</version>
</plugin>
</plugins>
</build>

</project>
</project>