Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROD-6663: Set up jenkins for auto deployment #5

Merged
merged 3 commits into from
May 4, 2023
Merged
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
49 changes: 49 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
library 'jenkins-shared-lib@main'

pipeline {
agent {
docker {
image 'swr.ap-southeast-3.myhuaweicloud.com/scantist-images/frontend-build:v1.1.1'
registryUrl 'https://swr.ap-southeast-3.myhuaweicloud.com'
registryCredentialsId 'hwc-swr-cred'
args '-u root:root -v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
GOOGLE_CHAT_TOKEN = credentials('google-chat-release-deployment-token')
GITHUB_CREDS = credentials('scantist-jenkins-bot')
SERVICE_ACCOUNT_KEY = credentials('scantist-v4-json')
}
stages {
stage('Download element-plus') {
steps {
sh'''
export GITHUB_OAUTH_TOKEN=$GITHUB_CREDS_PSW
bash scripts/download-element-plus
'''
}
}

stage('Build and upload to v4dev') {
environment {
GCP_CREDENTIALS_ID ='scantist-v4'
GCP_BUCKET = 'docs.scantist.io/'
GCP_FILE_PATTERN = 'docs/.vitepress/dist/**/*'
GCP_FILE_PATH_PREFIX = "docs/.vitepress/dist/"
}
steps {
sh '''
npm install
yarn docs:build
'''
step([$class: 'ClassicUploadStep',
credentialsId: env.GCP_CREDENTIALS_ID,
bucket: "gs://${env.GCP_BUCKET}",
pattern: env.GCP_FILE_PATTERN,
pathPrefix: env.GCP_FILE_PATH_PREFIX,
showInline: true])
pushHangoutsNotify("Deployed ${env.BRANCH_NAME} to docs.scantist.io.")
}
}
}
}
18 changes: 18 additions & 0 deletions scripts/download-element-plus
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

download_element_plus() {
version=$(jq -r '."dependencies"."element-plus"' package.json)
echo "Downloading $version"
tag=${version:18:10}
fetch --repo="https://github.com/scantist/element-plus" --tag="$tag" --release-asset="element-plus-$tag.tgz" .
}

main() {
download_element_plus
}

main