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

Commit

Permalink
chore: add Jenkinsfile for Javascript implementation (#29)
Browse files Browse the repository at this point in the history
* chore: add Jenkinsfile for Javascript implementation
* Change NPM package name

Fixes #28

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
  • Loading branch information
jeffmaury authored Jul 2, 2021
1 parent 565736c commit bb19654
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Alizer also offers a NPM package providing helpers for recognize languages/frame
The syntax is the following:

```
import * as recognizer from 'language-recognizer';
import * as recognizer from '@redhat-developer/alizer';
.....
Expand Down
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}"
}
}
}

}
2 changes: 1 addition & 1 deletion js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "language-recognizer",
"name": "@redhat-developer/alizer",
"version": "0.0.1",
"description": "",
"main": "lib/src/recognizer.js",
Expand Down

0 comments on commit bb19654

Please sign in to comment.