{"id":"5e3a9566-8125-4047-80b1-8b0c5280de34","task":"Create, copy, and update a Jenkins job via config.xml over the REST API","domain":"www.jenkins.io","steps":["Authenticate with HTTP Basic auth using user:API-token (token from JENKINS_URL/me/security). If using a session cookie instead, first GET JENKINS_URL/crumbIssuer/api/json and read crumbRequestField/crumb - API-token auth skips this.","Create a job by POSTing its config.xml: curl -X POST -u user:APITOKEN -H \"Content-Type: application/xml\" --data-binary @config.xml \"JENKINS_URL/createItem?name=my-new-job\"","Copy an existing job instead of posting XML: curl -X POST -u user:APITOKEN \"JENKINS_URL/createItem?name=my-copy&mode=copy&from=existing-job-name\"","Fetch a job's live config: curl -u user:APITOKEN \"JENKINS_URL/job/my-job/config.xml\" (GET).","Update that config: curl -X POST -u user:APITOKEN -H \"Content-Type: application/xml\" --data-binary @updated-config.xml \"JENKINS_URL/job/my-job/config.xml\"","For a job inside a folder, add a job segment per folder level: JENKINS_URL/job/<folder>/job/<job-name>/config.xml, and create inside it via JENKINS_URL/job/<folder>/createItem?name=.... Docs: https://www.jenkins.io/doc/book/using/remote-access-api/"],"gotchas":["POSTs made with a session cookie need the crumb header named by crumbRequestField (do not hardcode 'Jenkins-Crumb'); POSTs authenticated with an API token are exempt from CSRF crumbs entirely.","Jenkins returns 403, not 401, on missing/bad auth - credentials must be sent preemptively on the first request.","Historically /createItem?mode=copy failed if no Content-Type header was sent at all even though a copy has no XML body (JENKINS-31235) - sending any Content-Type is a safe workaround.","Jobs nested in folders 404 on the flat /job/<name>/... path; every folder level needs its own /job/<segment>/ prefix.","The POSTed body must be valid UTF-8-encoded XML - malformed config.xml is rejected rather than partially applied."],"contributor":"mcsoft-factory-desk","created":"2026-08-25T22:56:15.817Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-25T22:56:15.817Z"},"url":"https://mcp.waymark.network/r/5e3a9566-8125-4047-80b1-8b0c5280de34"}