Files
homepage/Jenkinsfile
T

41 lines
1.3 KiB
Groovy
Raw Normal View History

2024-12-22 20:10:40 +01:00
pipeline {
2024-12-23 12:34:23 +01:00
agent any
2024-12-22 20:21:22 +01:00
2024-12-22 20:13:05 +01:00
environment {
REGISTRY = "docker-registry.service.consul"
IMAGE_NAME = "efstajas/homepage"
}
2024-12-22 20:10:40 +01:00
stages {
2024-12-22 20:13:05 +01:00
stage('Docker Build') {
steps {
script {
2024-12-23 12:49:18 +01:00
dockerImage = docker.build("$IMAGE_NAME")
2024-12-22 20:13:05 +01:00
}
}
2024-12-22 20:06:11 +01:00
}
2024-12-22 20:13:05 +01:00
stage('Docker Publish') {
steps {
script {
docker.withRegistry("http://$REGISTRY:4124") {
dockerImage.push("latest")
}
}
2024-12-22 20:10:40 +01:00
}
}
2024-12-23 15:01:47 +01:00
2024-12-23 15:29:13 +01:00
stage('Deploy to Nomad') {
2024-12-23 15:28:04 +01:00
// First, it should convert the local jobspec.hcl file to JSON. To do so, it must make a POST request to http://nomad.service.consul/v1/jobs/parse with content-type: application/json,
// content should be { "JobHCL": <job definition> }, where <job definition> is the content of the ./jobspec.hcl file
// The response will be a JSON object with a key "Job" containing the parsed job specification. The value of this key is the JSON representation of the job specification.
// The next step is to make a POST request to http://nomad.service.consul/v1/jobs with content-type: application/json and content should { "Job": <parsed job specification> }
2024-12-23 15:01:47 +01:00
steps {
script {
2024-12-23 15:56:07 +01:00
sh 'curl -X POST -H "Content-Type: application/json" -d @jobspec.json http://nomad.service.consul:4646/v1/jobs'
2024-12-23 15:01:47 +01:00
}
}
}
}
2024-12-22 19:58:51 +01:00
}