diff --git a/Jenkinsfile b/Jenkinsfile index 7594545d..2ff6f8c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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/" + } } } } -} \ No newline at end of file +} diff --git a/webapp/index.html b/webapp/index.html index a683c108..d29c78eb 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -9,7 +9,7 @@ diff --git a/webapp/package.json b/webapp/package.json index c7543640..79295401 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -1,7 +1,7 @@ { "name": "webapp", "private": true, - "version": "1.0.1", + "version": "2.1", "type": "module", "scripts": { "dev": "vite",