Skip to content

Instantly share code, notes, and snippets.

@strangeman
Last active November 2, 2023 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strangeman/a7abc310940247730aaa24a22cdf19ba to your computer and use it in GitHub Desktop.
Save strangeman/a7abc310940247730aaa24a22cdf19ba to your computer and use it in GitHub Desktop.
Semaphore API Call Snippet for Jenkins
echo "DEBUG: got project_id ${project_id} and template_id ${template_id}"
withCredentials([[$class: 'StringBinding', credentialsId: 'semaphore-token', variable: 'bearer']]) {
httpRequest acceptType: 'APPLICATION_JSON', consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', customHeaders: [[name: 'Authorization', value: "Bearer ${env.bearer}"]], httpMode: 'POST', requestBody: """{
\"template_id\": ${template_id},
\"debug\": false,
\"dry_run\": false,
\"playbook\": \"\",
\"environment\": \"\"
}""", url: "https://ansible.ourdomain.com/api/project/${project_id}/tasks"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment