Skip to content
Open
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
44 changes: 25 additions & 19 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
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://18.219.166.107: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://18.219.166.107: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/"
}
}
}
}
}
}