-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (54 loc) · 2.01 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
pipeline {
agent {
label "jenkins-slave"
}
environment {
// Define the Task version to install
TASK_VERSION = '3.34.1'
// Determine the architecture and set the download URL for Task
TASK_DOWNLOAD_URL = ''
}
stages {
stage('Prepare Environment') {
steps {
script {
// Detect architecture
if (isUnix()) {
def taskDownloadUrl = ''
def arch = sh(script: 'uname -m', returnStdout: true).trim()
echo "Detected architecture: ${arch}"
// Set the download URL based on architecture
if (arch == 'x86_64') {
taskDownloadUrl = "https://github.com/go-task/task/releases/download/v${env.TASK_VERSION}/task_linux_amd64.tar.gz"
} else if (arch.startsWith('arm') || arch.startsWith('aarch64')) {
taskDownloadUrl = "https://github.com/go-task/task/releases/download/v${env.TASK_VERSION}/task_linux_arm64.tar.gz"
} else {
error "Unsupported architecture: ${arch}"
}
// Download and install Task
sh """
curl -sL ${taskDownloadUrl} -o task.tar.gz
tar -xzf task.tar.gz
mv task /tmp
/tmp/task --version
"""
} else {
error "Unsupported OS"
}
}
}
}
stage('Terraform plan and apply') {
steps {
sh "/tmp/task -t taskfile-infra.yml init"
sh "/tmp/task -t taskfile-infra.yml plan"
sh "/tmp/task -t taskfile-infra.yml apply"
}
}
}
post {
always {
sh "rm -f /tmp/task"
}
}
}