Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

chore: add Jenkinsfile for Javascript implementation #29

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions js/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env groovy

node('rhel8') {
stage('Checkout repo') {
deleteDir()
git url: "https://github.com/${params.FORK}/alizer.git", branch: params.BRANCH
}

stage('Install requirements') {
def nodeHome = tool 'nodejs-12.13.1'
env.PATH = "${nodeHome}/bin:${env.PATH}"
}

dir('js') {
stage('Build') {
sh "npm install"
sh "npm run compile"
}

stage('Test') {
sh "npm run test"
}

def packageJson = readJSON file: 'package.json'

stage('Package') {
sh "npm pack"
def packs = findFiles(glob: '**.tgz')
def packName = "redhat-developer-alizer-${packageJson.version}-${env.BUILD_NUMBER}.tgz"
sh "mv ${packs[0].name} ${packName}"
sh "ln -s ${packName} redhat-developer-alizer-latest.tgz"
}

if (params.UPLOAD_LOCATION) {
stage('Snapshot') {
def filesToPush = findFiles(glob: '**.tgz')
for (i = 0; i < filesToPush.length; i++) {
sh "rsync -Pzrlt --rsh=ssh --protocol=28 ${filesToPush[i].path} ${UPLOAD_LOCATION}/snapshots/alizer/"
}
}
}

if (publish.equals('true')) {
stage('Publish to NPM') {
withCredentials([[$class: 'StringBinding', credentialsId: 'npm-token', variable: 'TOKEN']]) {
sh "echo registry=https://registry.npmjs.com > .npmrc"
sh "echo //registry.npmjs.com/:_authToken=${TOKEN} >> .npmrc"
sh "npm publish"
}
currentBuild.keepLog = true
currentBuild.description = "${packageJson.version}.${env.BUILD_NUMBER}"
}
}
}

}