Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
126 lines (118 loc) · 4.84 KB
/
Copy pathJenkinsfile
File metadata and controls
126 lines (118 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!groovy
def isMaster() {
return (env.EFFECTIVE_BRANCH_NAME == 'main');
}
def isDevelop() {
return (env.EFFECTIVE_BRANCH_NAME == 'develop');
}
def isRelease() {
return (((String) env.EFFECTIVE_BRANCH_NAME).startsWith('release/'));
}
def isFeature() {
return (((String) env.EFFECTIVE_BRANCH_NAME).startsWith('feature/'));
}
def isBugfix() {
return (((String) env.EFFECTIVE_BRANCH_NAME).startsWith('bugfix/'));
}
def isHotfix() {
return (((String) env.EFFECTIVE_BRANCH_NAME).startsWith('hotfix/'));
}
def isReleasableBranch() {
return isMaster() || isRelease()
}
pipeline {
agent {
label 'el8'
}
parameters {
booleanParam(name: 'DEPLOY', defaultValue: false, description: 'Update package on the server')
string(name: 'SSH_IP', defaultValue: 'psb-demo.demo.rooxintra.net', description: 'Address of the server on which you want to update the package')
booleanParam(name: "CERTIFICATE", defaultValue: false, description: "Контрольное суммирование артефакта с помощью Сканер-ВС")
booleanParam(name: "DEPENDENCY_CHECK", defaultValue: false, description: "Проверка зависимостей на известные уязвимости")
booleanParam(name: "PRODUCTIVE_VERSION", defaultValue: false, description: "Check if version is productive")
}
environment {
CI = 'false'
GIT_REMOTE = sh(returnStdout: true, script: "git remote").trim()
EFFECTIVE_BRANCH_NAME = "${env.CHANGE_BRANCH ?: env.BRANCH_NAME}"
SAFE_BRANCH_NAME = "${env.EFFECTIVE_BRANCH_NAME}".replaceAll("[^\\w\\-_/]+", "-").replaceAll("/", "-").replaceAll("_", "-").trim().toLowerCase()
GIT_COMMIT = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%H'").trim()
GIT_URL = sh(returnStdout: true, script: "git config remote.origin.url").trim()
ARTIFACT_NAME = "uidm-react-lib"
PRODUCT_VERSION = "25.1"
INSTALL_TO_DIR = "/opt/nginx/www/widgets/uidm-react-lib"
SONAR_REPO_FILE = "${WORKSPACE}/${GIT_REPO_NAME}.scannerwork/scanner-report"
SONAR_SCANNER_HOME = tool "sonarscanner_base"
REPORT_DIR = "."
NPM_REGISTRY = "https://repo2.rooxcloud.com/customers/repository/npm-roox-hosted/"
SCANERVS_STATUS_PAGE_URL = "https://scanner-vs.rooxintra.net/reports/status_jenkins.html"
SCANERVS_SFTP_DST = "jenkins@scanner-vs.rooxintra.net:/var/www/shared/input"
SONAR_ENV = "${env.EFFECTIVE_BRANCH_NAME == 'main' ? 'SonarQube-master' : 'SonarQube-dev'}"
SONAR_BRANCH_NAME = "${env.EFFECTIVE_BRANCH_NAME}".replaceAll("[^\\w\\-_]+", "_")
SONAR_PROJECT_KEY = "${env.EFFECTIVE_BRANCH_NAME == 'main' ? 'uidm-react-lib' : "uidm-react-lib_${SONAR_BRANCH_NAME}"}"
}
tools {
nodejs 'NODEJS_20.18.0'
}
stages {
stage('Init environment') {
steps {
dir(path: 'arm-sso-lib'){
ansiColor('xterm') {
script {
sh '''
npm -v
node -v
'''
}
}
}
}
}
stage('Install deps') {
steps {
dir(path: 'arm-sso-lib') {
ansiColor('xterm') {
sh 'yarn install --no-progress --non-interactive --pure-lockfile'
}
}
}
}
stage('Build package') {
steps {
dir(path: 'arm-sso-lib') {
ansiColor('xterm') {
script {
sh 'yarn build'
}
}
}
}
}
stage('Publish package') {
when {
expression { isDevelop() }
}
steps {
dir(path: 'arm-sso-lib') {
withCredentials([usernamePassword(credentialsId: 'be012fb5-bdcb-4383-96d3-d4e5d7bbaf53', passwordVariable: 'NPM_PASSWORD', usernameVariable: 'NPM_USERNAME')]) {
ansiColor('xterm') {
script {
NPM_AUTH_STRING=sh(script: "echo -n ${NPM_USERNAME}:${NPM_PASSWORD} | base64", returnStdout: true).trim()
writeFile file: '.npmrc', text: "registry=${NPM_REGISTRY}\n//repo2.rooxcloud.com/customers/repository/npm-roox-hosted/:_auth=${NPM_AUTH_STRING}\nalways-auth = true"
sh 'npm publish'
}
}
}
}
}
}
}
post {
always{
dir(path: 'arm-sso-lib') {
sh 'rm .npmrc'
}
}
}
}