Skip to content

Instantly share code, notes, and snippets.

@qzm
Last active April 2, 2023 18:36
Show Gist options
  • Save qzm/f8921c0b7032ab7a6497ea92eb605438 to your computer and use it in GitHub Desktop.
Save qzm/f8921c0b7032ab7a6497ea92eb605438 to your computer and use it in GitHub Desktop.
Vue.js / Jenkinsfile /Pipelines
pipeline {
agent {
docker {
image 'node'
}
}
stages {
stage('Clone Sources') {
steps {
git 'https://gitlab.com/chiminyau/ci-test.git'
}
}
stage('Information') {
steps {
sh 'node -v'
sh 'npm -v'
}
}
stage('Config') {
steps {
sh 'npm set registry https://registry.npm.taobao.org'
sh 'npm set disturl https://npm.taobao.org/dist'
sh 'npm set chromedriver_cdnurl http://cdn.npm.taobao.org/dist/chromedriver'
sh 'npm set operadriver_cdnurl http://cdn.npm.taobao.org/dist/operadriver'
sh 'npm set phantomjs_cdnurl http://cdn.npm.taobao.org/dist/phantomjs'
sh 'npm set fse_binary_host_mirror https://npm.taobao.org/mirrors/fsevents'
sh 'npm set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass'
sh 'npm set electron_mirror http://cdn.npm.taobao.org/dist/electron/'
}
}
stage('Dependencies') {
steps {
sh 'npm install'
}
}
stage('Unit Test') {
steps {
sh 'npm run unit'
}
}
stage('E2E Test') {
steps {
sh 'npm run e2e'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Artifacts') {
steps {
sh 'tar -czf dist.tar.gz ./dist'
stash 'dist.tar.gz'
stash 'Dockerfile'
stash 'nginx.conf'
archiveArtifacts artifacts: 'dist.tar.gz', fingerprint: true
}
}
stage('Docker Image') {
agent {
docker {
image 'docker:dind'
}
}
steps {
sh 'docker -v'
unstash 'dist.tar.gz'
unstash 'Dockerfile'
unstash 'nginx.conf'
sh 'docker build -t registry.gitlab.com/chiminyau/ci-test:jenkins .'
}
}
}
}
@gtsigner
Copy link

hellp,I ran into problems using your script。I have no authority to perform any modified file paths
image

@step4
Copy link

step4 commented Nov 20, 2018

For me it helped to add a environment block with the HOME variable under the agent, like this:

agent {
        docker {
            image 'node:10-alpine'
            args '-p 4000:4000'
        }
}
environment {
        HOME= '.'
}

@srijanr
Copy link

srijanr commented Jan 28, 2020

What is I want to push the content of dist folder to a azure blob storage?

@m-yahya
Copy link

m-yahya commented Oct 29, 2020

Screenshot from 2020-10-29 10-16-48
any help on how to fix Restore files previously stashed?
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment