-
Notifications
You must be signed in to change notification settings - Fork 87
/
Jenkinsfile-UCAN
81 lines (74 loc) · 1.75 KB
/
Jenkinsfile-UCAN
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
@Library('jenkins-library') _
def agentImage = 'docker.soramitsu.co.jp/build-tools/node:14-ubuntu-extended'
def agentLabel = 'docker-build-agent'
def gitHubUser = 'sorabot'
def gitAddrRegex = ''
pipeline {
triggers {
cron('H H */9 * *')
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '40'))
timestamps()
}
agent {
docker {
label "${agentLabel}"
image "${agentImage}"
registryUrl 'https://docker.soramitsu.co.jp'
registryCredentialsId 'bot-build-tools-ro'
alwaysPull true
}
}
environment {
API_KEY = credentials('nft-storage-api-key')
GH_TOKEN = credentials('sorabot-github-token')
}
stages {
stage('Install dependencies') {
steps {
script {
sh """
cd scripts/ucan
npm install
"""
}
}
}
stage('UCAN generation') {
steps {
script {
sh """
cd scripts/ucan
node generateNftServiceKeypair.js
mv ucan.json ../../
"""
}
}
}
stage("Copy token to deploy branch'") {
steps {
script {
gitAddrRegex = env.GIT_URL.replaceFirst("^http[s]?://","")
sh """
git checkout -b ucan-temp
find -maxdepth 1 ! -name ucan.json ! -name .git ! -name . -exec rm -r {} \\;
git config user.email "[email protected]"
git config user.name "${gitHubUser}"
git add --all
git commit -a -m "copy"
git push https://${gitHubUser}:${GH_TOKEN}@${gitAddrRegex} ucan-temp:ucan-token --force
"""
}
}
}
}
post {
cleanup {
script {
cleanWs()
}
}
}
}