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: 25 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
pipeline {
agent any
environment {
// More detail:
// https://jenkins.io/doc/book/pipeline/jenkinsfile/#usernames-and-passwords
NEXUS_CRED = credentials('nexus')
}


stages {
stage('Build') {
stage('Build & Release') {
steps {
echo 'Building..'
script {
def packageJSON = readJSON file: 'webapp/package.json'
def packageJSONVersion = packageJSON.version
sh "echo '${packageJSONVersion}'"

echo 'Building'
sh 'cd webapp && npm install && npm run build'

echo 'Releasing'
sh "zip webapp/dist-'${packageJSONVersion}'.zip -r webapp/dist"
sh "curl -v -u admin:Admin123* --upload-file webapp/dist-'${packageJSONVersion}'.zip http://35.183.142.16/:8081/repository/lms/"
}
}
}
stage('Test') {
steps {
echo 'Testing..'
sh 'cd webapp && sudo docker container run --rm -e SONAR_HOST_URL="http://20.172.187.108:9000" -e SONAR_LOGIN="sqp_cae41e62e13793ff17d58483fb6fb82602fe2b48" -v ".:/usr/src" sonarsource/sonar-scanner-cli -Dsonar.projectKey=lms'
}
}
stage('Release') {

stage('Deploy') {
steps {
echo 'Release Nexus'
sh 'rm -rf *.zip'
sh 'cd webapp && zip dist-${BUILD_NUMBER}.zip -r dist'
sh 'cd webapp && curl -v -u $Username:$Password --upload-file dist-${BUILD_NUMBER}.zip http://20.172.187.108:8081/repository/lms/'
script {
def packageJSON = readJSON file: 'webapp/package.json'
def packageJSONVersion = packageJSON.version
echo 'Deploying....'
sh "curl -u admin:Admin123 -X GET \'http://35.183.142.16/:8081/repository/lms/dist-${packageJSONVersion}.zip\' --output dist-'${packageJSONVersion}'.zip"
sh 'sudo rm -rf /var/www/html/*'
sh "sudo unzip -o dist-'${packageJSONVersion}'.zip"
sh "sudo cp -r webapp/dist/* /var/www/html/"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<style>
body {
color: 'white';
background-color: green;
background-color: grey;
}
</style>
</head>
Expand Down
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webapp",
"private": true,
"version": "1.0.1",
"version": "2.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down