From c9a95eb81b7513c1b49b12abe2a4d1b3cf4cfd17 Mon Sep 17 00:00:00 2001 From: Georgios Jason Efstathiou Date: Mon, 23 Dec 2024 15:28:04 +0100 Subject: [PATCH] try this --- Jenkinsfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 87a6896..d2d8bff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,10 +25,15 @@ pipeline { } } - stage('Deploy to Nomad by running jobspec.hcl') { + stage('Deploy to Nomad) { + // 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": }, where 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": } steps { script { - sh 'nomad job run jobspec.hcl -address=http://nomad.service.consul:4646' + sh 'curl -X POST -H "Content-Type: application/json" -d "{ \"JobHCL\": \"$(cat jobspec.hcl)\" }" http://nomad.service.consul/v1/jobs/parse > parsed_job.json' + sh 'curl -X POST -H "Content-Type: application/json" -d "{ \"Job\": $(cat parsed_job.json) }" http://nomad.service.consul/v1/jobs' } } }