-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
70 lines (70 loc) · 3 KB
/
Jenkinsfile
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
properties([pipelineTriggers([githubPush()])])
node {
stage('preparation') {
echo sh(script: 'env|sort', returnStdout: true)
git(
url: 'https://github.com/SwissTierrasColombia/st-site-web.git',
branch: "${env.BRANCH_NAME}"
)
}
stage('Build') {
sh '''
cat << EOF > src/environments/environment.prod.ts
const apiBaseUrl = 'https://apist.proadmintierra.info';
export const environment = {
production: true,
apiBaseUrl,
apiBaseUrlPrefix: apiBaseUrl + '/api',
nameTokenSession: 'access_token_st',
clientUsername: '${env.clientUsernameMasterST}',
clientPassword: '${env.clientPasswordMasterST}'
};
EOF
'''
sh '''
cat << EOF > src/environments/environment.ts
const apiBaseUrl = 'http://192.168.1.102:8090';
export const environment = {
production: false,
apiBaseUrl,
apiBaseUrlPrefix: apiBaseUrl + '/api',
nameTokenSession: 'access_token_st',
clientUsername: '${env.clientUsernameDevelopST}',
clientPassword: '${env.clientPasswordDevelopST}'
};
EOF
'''
env.GIT_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
env.GIT_BRANCH = sh(script: 'git rev-parse --abbrev-ref HEAD', returnStdout: true).trim()
sh "echo current commit ${env.GIT_COMMIT}"
sh "echo current branch ${env.GIT_BRANCH}"
emailext (
subject: "START: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
to: "${correos}"
)
nodejs(nodeJSInstallationName: 'node-10.19.0', configId: null) {
sh '''
npm install
npm run-script build
tar czf dist.tar.gz dist
'''
}
}
stage ('Deploy-master') {
when { branch 'master' }
sh 'ssh [email protected] rm -rf /var/www/st/html/dist'
sh "scp dist.tar.gz [email protected]:/var/www/st/html/dist-${env.GIT_BRANCH}-${env.GIT_COMMIT}.tar.gz"
sh "ssh [email protected] tar --overwrite -xf /var/www/st/html/dist-master-${env.GIT_COMMIT}.tar.gz -C /var/www/st/html/"
}
stage('Results') {
emailext (
subject: "FINISHED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FINISHED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>
Espero que todo salga bien :P http://st-agencia.proadmintierra.info/""",
to: "${correos}"
)
}
}