diff --git a/build/dev/Jenkinsfile b/build/dev/Jenkinsfile index 043fcf2..8a6ee39 100644 --- a/build/dev/Jenkinsfile +++ b/build/dev/Jenkinsfile @@ -1,5 +1,3 @@ stage ('production build') { - steps { - sh 'npm run build' - } + sh 'npm run build' } diff --git a/build/prod/Jenkinsfile b/build/prod/Jenkinsfile index 5fbaed0..1982507 100644 --- a/build/prod/Jenkinsfile +++ b/build/prod/Jenkinsfile @@ -1,5 +1,3 @@ stage ('production build') { - steps { - sh 'npm run build:prod' - } + sh 'npm run build:prod' } diff --git a/clean-all/Jenkinsfile b/clean-all/Jenkinsfile new file mode 100644 index 0000000..4174340 --- /dev/null +++ b/clean-all/Jenkinsfile @@ -0,0 +1,5 @@ +stage('clean-all') { + sh 'rm -rf .[!.]*' + sh 'rm -rf ./*' + sh 'ls -a' +} diff --git a/install/Jenkinsfile b/install/Jenkinsfile index 29be46c..9233646 100644 --- a/install/Jenkinsfile +++ b/install/Jenkinsfile @@ -1,6 +1,4 @@ stage('install') { - steps { - echo 'starting installing' - sh 'npm install' - } + echo 'starting installing' + sh 'npm install' } \ No newline at end of file diff --git a/predeploy/Jenkinsfile b/predeploy/Jenkinsfile index dd2249c..f517b3f 100644 --- a/predeploy/Jenkinsfile +++ b/predeploy/Jenkinsfile @@ -1,22 +1,18 @@ stage ('predeploy') { - steps { - echo 'checking tag' - script { - if (sh(returnStdout: true, script: "git tag --contains").trim()) { - def tag = sh(returnStdout: true, script: "git tag --contains").trim() - echo 'found tag ' + tag - sh "cd dist ; echo 'mkdir ${tag}; mv ./master/* ./${tag}; rm -r -d ./master; rm version.sh' > version.sh" - } else { - echo 'tag not found' - sh "cd dist ; echo 'rm version.sh' > version.sh" - } - } - } - - stage ('archiving') { - steps { - // Archive the build output artifacts. - archiveArtifacts artifacts: 'dist/*' + echo 'checking tag' + script { + if (sh(returnStdout: true, script: "git tag --contains").trim()) { + def tag = sh(returnStdout: true, script: "git tag --contains").trim() + echo 'found tag ' + tag + sh "cd dist ; echo 'mkdir ${tag}; mv ./master/* ./${tag}; rm -r -d ./master; rm version.sh' > version.sh" + } else { + echo 'tag not found' + sh "cd dist ; echo 'rm version.sh' > version.sh" } } } + +stage ('archiving') { + // Archive the build output artifacts. + archiveArtifacts artifacts: 'dist/*' +} diff --git a/prepare/Jenkinsfile b/prepare/Jenkinsfile deleted file mode 100644 index d8cbbea..0000000 --- a/prepare/Jenkinsfile +++ /dev/null @@ -1,7 +0,0 @@ -stage('prepare') { - steps { - sh 'rm -rf .[!.]*' - sh 'rm -rf ./*' - sh 'ls -a' - } -} diff --git a/publish/Jenkinsfile b/publish/Jenkinsfile index 42d1475..b24eec9 100644 --- a/publish/Jenkinsfile +++ b/publish/Jenkinsfile @@ -1,14 +1,12 @@ stage ('publish') { - steps { - echo 'checking tag' - script { - def tag = sh(returnStdout: true, script: "git tag --contains").trim() - if (tag) { - echo 'found tag ' + tag - sh 'npm publish' - } else { - echo 'tag not found' - } + echo 'checking tag' + script { + def tag = sh(returnStdout: true, script: "git tag --contains").trim() + if (tag) { + echo 'found tag ' + tag + sh 'npm publish --access public' + } else { + echo 'tag not found' } } } diff --git a/stats/Jenkinsfile b/stats/Jenkinsfile index 0cdcedd..6afb923 100644 --- a/stats/Jenkinsfile +++ b/stats/Jenkinsfile @@ -1,10 +1,8 @@ stage('stats') { - steps { - sh 'node -v' - sh 'npm -v' - sh 'ls -a' - sh 'df -h' - sh 'free -m' - sh 'vmstat -s' - } + sh 'node -v' + sh 'npm -v' + sh 'ls -a' + sh 'df -h' + sh 'free -m' + sh 'vmstat -s' } diff --git a/template b/template new file mode 100644 index 0000000..d5921c9 --- /dev/null +++ b/template @@ -0,0 +1,35 @@ +def clean () { + sh 'rm -rf .[!.]*' + sh 'rm -rf ./*' + sh 'ls -a' +} + +def clone (String repoPath, String folder) { + echo 'cloning...' + sh "git clone ${repoPath}.git tmp" + sh "mkdir -p ${folder}" + sh "mv ./tmp/* ./${folder}" + sh "mv ./tmp/.[!.]* ./${folder}" +} + +def loadScript (String scriptName) { + load "tmp--jfiles/${scriptName}/Jenkinsfile" +} + +pipeline { + agent any + + stages { + stage('processing') { + steps { + clean() + clone('https://aaprimakov@bitbucket.org/jsadvance20201/jenkins', 'tmp--jfiles') + loadScript('stats') + clone('https://aaprimakov@bitbucket.org/jsadvance20201/dev-server', './') + loadScript('publish') + loadScript('clean-all') + } + } + } +} + diff --git a/ui/Jenkinsfile b/ui/Jenkinsfile index b1635d6..7265c87 100644 --- a/ui/Jenkinsfile +++ b/ui/Jenkinsfile @@ -1,6 +1,4 @@ stage('ui tests') { - steps { - echo 'ui tests' - sh 'npm run test:ui' - } + echo 'ui tests' + sh 'npm run test:ui' } diff --git a/unit/Jenkinsfile b/unit/Jenkinsfile index f7bede6..d884d94 100644 --- a/unit/Jenkinsfile +++ b/unit/Jenkinsfile @@ -1,6 +1,4 @@ stage('unit tests') { - steps { - echo 'runing tests...' - sh 'npm run test' - } + echo 'runing tests...' + sh 'npm run test' } \ No newline at end of file