Skip to content

Commit

Permalink
some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainPenbase committed Jul 8, 2021
1 parent 123106f commit f6c003d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 34 deletions.
69 changes: 43 additions & 26 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!groovy
/* groovylint-disable MethodReturnTypeRequired, NoDef, VariableTypeRequired */
@Library('jenkins-library@master') _
import com.penbase.rocketchat.RocketChat
import jenkins.plugins.rocketchatnotifier.*
Expand All @@ -9,20 +10,19 @@ def FULL_BUILD = currentBuild.rawBuild.getCause(jenkins.branch.BranchEventCause)
//currentBuild.description = FULL_BUILD ? '<span style="color: red"><b>FULL BUILD</b> (with integration tests)</span>' : 'SIMPLE BUILD (no integration tests)'

pipeline {
agent { label 'slave-mac-sylvain'}
agent { label 'slave-mac-sylvain' }

environment {
// Github variables
GITHUB_PROJECT = "Penbase/cordova-plugin-fcm-with-dependecy-updated"
GITHUB_PROJECT = 'Penbase/cordova-plugin-fcm-with-dependecy-updated'
GITHUB_TOKEN = credentials('Github-token')
// Build variables
FULL_BUILD = "$FULL_BUILD"
IS_PR = "$BRANCH_NAME".startsWith("PR-")
PROJECT_VERSION = "$BRANCH_NAME".replaceAll("[^a-zA-Z0-9_]", "_")
IS_PR = "$BRANCH_NAME".startsWith('PR-')
PROJECT_VERSION = "$BRANCH_NAME".replaceAll('[^a-zA-Z0-9_]', '_')
// Chemin du package.json dans lequel on modifie la version
VERSION_LOCATION = "package.json"
ROCKETCHAT_PREPROD_CHAN = "jenkins_mobile"
PROJECT_NAME = "@penbase/cordova-plugin-fcm-with-dependecy-updated"
ROCKETCHAT_PREPROD_CHAN = 'jenkins_mobile'
PROJECT_NAME = '@penbase/cordova-plugin-fcm-with-dependecy-updated'
}

options {
Expand All @@ -33,13 +33,13 @@ pipeline {
stage('Build library and publish') {
steps {
script {
sh "npm run build"
if (env.TAG_NAME) {
updateVersion(env.TAG_NAME);
sh "npm publish"
sh 'npm run build'
if (env.TAG_NAME) {
updateVersion(env.TAG_NAME)
sh 'npm publish'
} else {
sh "echo No tag found. There is nothing to build and publish"
}
sh 'echo No tag found. There is nothing to build and publish'
}
}
}
}
Expand All @@ -52,18 +52,18 @@ pipeline {
}
steps {
script {
def res = "";
res += ":email: Mise en production de *"+PROJECT_NAME+" v${env.TAG_NAME}* terminée"
def res = ''
res += ':email: Mise en production de *' + PROJECT_NAME + " v${env.TAG_NAME}* terminée"
res += "\nDependence npm : `\"@penbase/cordova-plugin-fcm-with-dependecy-updated\" : \"${env.TAG_NAME}\"`"
println res

//Publish to rocket chat !

def chan = ROCKETCHAT_PREPROD_CHAN
if (RocketChat.sendMessage(res, chan)) {
println "Message sent to rocketchat into #" + chan
println 'Message sent to rocketchat into #' + chan
} else {
println "Unable to send message to rocketchat into #" + chan
println 'Unable to send message to rocketchat into #' + chan
}
}
}
Expand All @@ -74,7 +74,7 @@ pipeline {
script {
withCredentials([[$class: 'SSHUserPrivateKeyBinding', credentialsId: '1cc7647c-c0b0-4a9b-ae3b-9d8832a6ef7d', usernameVariable: 'USERNAME', keyFileVariable: 'IDENTITY_FILE']]) {
withEnv(["GIT_SSH_COMMAND=ssh -i $IDENTITY_FILE"]) {
sh "echo succeeded"
sh 'echo succeeded'
}
}
}
Expand All @@ -86,14 +86,31 @@ pipeline {
}

def updateVersion(String newVersion) {
sh "echo updateVersion method"
def packageJson = readJSON file: VERSION_LOCATION
sh "echo packageJson.version=" + packageJson.version
if (newVersion.startsWith("v")) {
newVersion = newVersion.substring(1)
sh "echo newVersion = " + newVersion
updateVersionJSONFile(newVersion, 'package.json')
updateVersionJSONFile(newVersion, 'ionic/package.json')
updateVersionJSONFile(newVersion, 'ionic/ngx/package.json')
updateVersionJSONFile(newVersion, 'ionic/v4/package.json')
updateVersionXMLFile(newVersion, 'plugin.xml')
}

def updateVersionJSONFile(String newVersion, String jsonFilePath) {
sh 'echo updateVersion method'
/* groovylint-disable-next-line VariableTypeRequired */
def packageJson = readJSON file: jsonFilePath
sh 'echo packageJson.version=' + jsonFilePath.version
if (newVersion.startsWith('v')) {
/* groovylint-disable-next-line ParameterReassignment, UnnecessarySubstring */
newVersion = newVersion.substring(1)
sh 'echo newVersion = ' + newVersion
}
packageJson.version = newVersion
writeJSON file: VERSION_LOCATION, json: packageJson

writeJSON file: jsonFilePath, json: packageJson
}

def updateVersionXMLFile(String newVersion, String xmlFilePath){
def xml = readFile xmlFilePath
def rootNode = new XmlParser().parseText(xml)
print rootNode['version']
rootNode['version'] = newVersion
print rootNode['version']
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "7.8.2-penbase",
"name": "@penbase/cordova-plugin-fcm-with-dependecy-updated",
"version": "7.8.3",
"name": "penbase-cordova-plugin-fcm-with-dependecy-updated",
"cordova_name": "Cordova FCM Push Plugin",
"description": "Google Firebase Cloud Messaging Cordova Push Plugin fork with dependecy updated",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="penbase-cordova-plugin-fcm-with-dependecy-updated" version="7.8.2">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="penbase-cordova-plugin-fcm-with-dependecy-updated" version="7.8.3">
<name>Cordova FCM Push Plugin</name>
<description>Google Firebase Cloud Messaging Cordova Push Plugin fork with dependecy updated</description>
<license>MIT</license>
Expand Down
3 changes: 1 addition & 2 deletions scripts/install_ionic_dependencies.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cd node_modules
cd @penbase
cd cordova-plugin-fcm-with-dependecy-updated
cd penbase-cordova-plugin-fcm-with-dependecy-updated
cd scripts
node install_ionic_dependencies.js ionic
node install_ionic_dependencies.js ionic/ngx
Expand Down
6 changes: 3 additions & 3 deletions scripts/install_ionic_dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const shouldInstallIonicDependencies = function () {
const fs = require('fs');
const packageFilePath = `${process.cwd()}/../../../package.json`;
if (!helpers.fileExists(packageFilePath)) {
helpers.logWarning('package.json was not found.');
helpers.logWarning('package.json was not found at path '+packageFilePath);
helpers.logWarning('Ionic dependencies omission cannot be safely skipped.');
return true;
}
Expand Down Expand Up @@ -40,7 +40,7 @@ const installIonicDependencies = function () {
} catch (error) {
helpers.logError(`Failed change directory to ${fullDestPath}!`, error);
helpers.logError(
`Please run \`cd node_modules/@penbase/cordova-plugin-fcm-with-dependecy-updated/${DEST_PATH}; npm install\` manually`
`Please run \`cd node_modules/penbase-cordova-plugin-fcm-with-dependecy-updated/${DEST_PATH}; npm install\` manually`
);
return;
}
Expand All @@ -51,7 +51,7 @@ const installIonicDependencies = function () {
.catch(function (e) {
helpers.logError('Failed to auto install Ionic dependencies!', e);
helpers.logError(
`Please run \`cd node_modules/@penbase/cordova-plugin-fcm-with-dependecy-updated/${DEST_PATH}; npm install\` manually`
`Please run \`cd node_modules/penbase-cordova-plugin-fcm-with-dependecy-updated/${DEST_PATH}; npm install\` manually`
);
})
.then(function (output) {
Expand Down

0 comments on commit f6c003d

Please sign in to comment.