-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsfileDeploy
69 lines (61 loc) · 3.05 KB
/
JenkinsfileDeploy
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
node('docker') {
// Global variables
def userInput
stage('Set properties') {
timeout(time: 5, unit: 'MINUTES') {
userInput = input(
id: 'select-deployment',
message: 'Select environment & service',
parameters : [
string(name: 'targetRemoteHost', description: 'Hostname where to deploy the subgraph', defaultValue: '', trim: true),
string(name: 'networkName', description: 'Network Name', defaultValue: 'bellecour', trim: true),
string(name: 'voucherHubAddress', description: 'Voucher Hub Address', defaultValue: '0x3137B6DF4f36D338b82260eDBB2E7bab034AFEda', trim: true),
string(name: 'voucherHubStartBlock', description: 'Start Block for Voucher Hub', defaultValue: '30306387', trim: true),
string(name: 'versionLabel', description: 'Version Label for Subgraph Deployment', defaultValue: 'develop', trim: true),
string(name: 'dockerImageVersion', description: 'Version of the deployer docker image to use', defaultValue: '', trim: true)
]
)
}
println """
Target remote host env: $userInput.targetRemoteHost
Graph Node URL: http://$userInput.targetRemoteHost:8020
IPFS URL: http://$userInput.targetRemoteHost:5001
Network Name: $userInput.networkName
Voucher Hub Address: $userInput.voucherHubAddress
Start Block: $userInput.voucherHubStartBlock
Version Label: $userInput.versionLabel
Deployer image version: $userInput.dockerImageVersion
"""
if (!(userInput.dockerImageVersion?.trim())) {
error "docker image version parameter cannot be null or empty."
}
}
stage('Clean Workspace') {
cleanWs()
}
stage('Checkout scm') {
checkout scm
}
stage('Run operation') {
withCredentials([
usernamePassword(credentialsId: 'docker-regis', usernameVariable: 'username', passwordVariable: 'password')
]) {
// Login to download Docker image
sh "echo -n '${password}' | docker login --username '${username}' --password-stdin docker-regis.iex.ec"
// Run the container for subgraph deployment
sh """
docker run \
--rm \
-e NETWORK_NAME='$userInput.networkName' \
-e VOUCHER_HUB_ADDRESS='$userInput.voucherHubAddress' \
-e VOUCHER_HUB_START_BLOCK='$userInput.voucherHubStartBlock' \
-e IPFS_URL='http://$userInput.targetRemoteHost:5001' \
-e GRAPHNODE_URL='http://$userInput.targetRemoteHost:8020' \
-e VERSION_LABEL='$userInput.versionLabel' \
docker-regis.iex.ec/voucher-subgraph-deployer:$userInput.dockerImageVersion
"""
// Logout to remove docker credentials
sh "docker logout docker-regis.iex.ec"
}
}
}