{"id":24969466,"url":"https://github.com/intrepidpursuits/jenkins-swift","last_synced_at":"2025-09-13T01:38:50.772Z","repository":{"id":151543759,"uuid":"66042593","full_name":"IntrepidPursuits/Jenkins-swift","owner":"IntrepidPursuits","description":"Swift client for Jenkins servers","archived":false,"fork":false,"pushed_at":"2016-11-20T07:11:27.000Z","size":61,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-11T04:41:37.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IntrepidPursuits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-19T01:28:42.000Z","updated_at":"2024-02-20T08:26:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"897f8657-f0ed-41a1-a75e-19700e3669f6","html_url":"https://github.com/IntrepidPursuits/Jenkins-swift","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/IntrepidPursuits/Jenkins-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2FJenkins-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2FJenkins-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2FJenkins-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2FJenkins-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IntrepidPursuits","download_url":"https://codeload.github.com/IntrepidPursuits/Jenkins-swift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2FJenkins-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274907721,"owners_count":25371817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-03T14:38:21.127Z","updated_at":"2025-09-13T01:38:50.752Z","avatar_url":"https://github.com/IntrepidPursuits.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jenkins-Swift\n---\n![Latest](http://img.shields.io/badge/Latest-0.0.6-brightgreen.svg)\n![Swift](http://img.shields.io/badge/swift-3.0-brightgreen.svg)\n[![Build Status](https://travis-ci.org/IntrepidPursuits/Jenkins-swift.svg?branch=master)](https://travis-ci.org/IntrepidPursuits/Jenkins-swift)\n\nJenkins-Swift is a Jenkins CI client, written in Swift for MacOS. The client uses a development snapshot of Swift 3. The project will be updated to follow the latest Swift 3 snapshots as they're released.\n\nThe client allows for some simple control of Jenkins jobs and builds. With Jenkins-Swift you can accomplish a variety of tasks including:\n  - Fetching all the jobs on your Jenkins servers\n  - Fetching individual jobs\n  - Creating, Updating and copying jobs\n  - Deleting jobs\n  - Retrieving information about the builds for a jobs\n\n___\n\n## Connecting\n\nInitializing the client with the hostname, or IP address of Jenkins, as well as your port, username, API token and optionally a path to where your jobs are located and the transport method.\n\nFor example if your jobs live at `http://jenkins.myHost.com:8080/jobs/`\n\nYou can initialize the jenkins client like so:\n\n    jenkins = try Jenkins(host: \"jenkins.myHost.com\",\n                           port: 8080,\n                           user: \"MyUsername\",\n                          token: \"MyAPIToken\",\n                           path: \"jobs\")\n\nThe client will throw an error if the URL it builds from this data is invalid.\n\nYou can find your API token by logging into Jenkins and going to the `Configure` section of your profile. This section will have a button titled `Show API Token` to get your token. It's recommended to create a new user if deploying the Jenkins client on a server.\n\n___\n\n## Models\n\nJenkins passes partial objects back from calls that can potentially return a lot of data. Specifically this happens when requesting all jobs, or all builds for a job. The objects returned generally will only include a `name`, `url`, and possibly an `id`.\n\nFetching a single job or a single build will return all of the data associated with that object.\n\n___\n\n## Functions\n\n#### Fetch Single Job\n\nFetching jobs is as simple as passing a name, or a Job object to one of the fetch functions.\n\n    jenkins.fetch(\"MyProject\") { job in\n      if let job = job {\n        print(job)\n      }\n      ...\n    }\n\nPassing a job object achieves the same effect, and serves as a convenience method.\n\n#### Fetch All Jobs\n\nFetching all jobs will return partial job objects:\n\n    jenkins.fetchJobs { jobs in\n      print(\"Number of jobs: \\(jobs.count)\")\n      ...\n    }\n\n#### Fetch Job Configuration XML\n\nYou may also wish to fetch the configuration for a job on Jenkins. This configuration is the XML tree used to create and update jobs. Currently no client side parsing is done, and the XML is passed back to the fetch configuration function.\n\n    jenkins.fetchJobConfiguration(\"MyProject\") { xml, error in\n      if let error = error {\n        print(error)\n        return\n      }\n\n      print(\"Xml Length: \\(xml.characters.count)\")\n    }\n\nThe XML passed back from this function can be used later to create a new job, or can be updated and uploaded to update the original project it was pulled from.\n\n#### Create Job\n\nCreating a job requires valid Jenkins configuration xml. An example of this XML can be found by fetching the configuration from an existing job on your system.\n\n    jenkins.create(\"MyNewProject\", configuration: response) { error in\n      if let error = error {\n        print(error)\n        return\n      }\n\n      print(\"Created Project\")\n    }\n\n#### Update Job\n\nSimilar to creating a project, updating a project only requires valid Jenkins configuration XML and a call to the update function\n\n    jenkins.update(\"MyExistingProject\", configuration: response) { error in\n      if let error = error {\n        print(error)\n        return\n      }\n\n      print(\"Updated Project\")\n    }\n\n#### Update Job Description\n\nSometimes you may want to update the description of the project without going through the hassle of reading and writing configuration XML. Use the `Update` method and pass in a description parameter instead of a configuration.\n\n    jenkins.update(\"MyProject\", description: updateString) { error in\n      if let error = error {\n        print(\"Error Updating Description: \\(error)\")\n        return\n      }\n\n      print(\"Description Updated\")\n    }\n\n#### Copy Job\n\nJenkins includes a native web-api call for copying jobs that makes the process a simple. Call the copy method passing in the existing project name, and the name of the new project.\n\n    jenkins.copy(\"oldProjectToCopy\", to: \"MyNewProject\") { error in\n      if let error = error {\n        print(error)\n        return\n      }\n\n      print(\"Copied project\")\n    }\n\n#### Delete Job\n\nCall the delete method and pass in a job to delete it from Jenkins. There's no validation here, and the call is destructive. We recommend you use the `disable` function instead of deleting a project.\n\n    jenkins.delete(\"MyJobToDelete\") { error in\n      ...\n      print(\"Deleted \\(job)\")\n    }\n\n#### Enabling and Disabling Jobs\n\nBoth enabling and disabling require a simple call with the name of the project.\n\n    // Disable job\n    jenkins.disable(job: \"MyProject\") { error in\n      if let error = error {\n        print(\"Error disabling job: \\(error)\")\n        return\n      }\n\n      print(\"Disabled job\")\n    }\n\n    // Enable job\n    jenkins.enable(job: \"MyProject\") { error in\n      if let error = error {\n        print(\"Error enabling job: \\(error)\")\n        return\n      }\n\n      print(\"Enabled job\")\n    }\n\n#### Building a Job\n\nBuilding a job requires using 1 of 2 methods, depending on whether or not your project requires parameters. In both cases, you call the `build` method, and optionally pass in parameters. If parameters are passed in, the client will use the appropriate path to build the project with parameters. If parameters are required but aren't passed into the function, Jenkins will return an error.\n\n    // Build without parameters\n    jenkins.build(\"MyProject\") { error in\n        if let error = error {\n            print(error)\n            return\n        }\n\n        print(\"Built Job Without Parameters\")\n    }\n\n    // Build with parameters\n\n    let parameters: [String : String] = [\n        \"SlackChannel\" : \"MyProject-Channel\",\n        \"Configuration\" : \"Test\",\n        \"isReleaseBuild\" : \"true\"\n    ]\n\n    jenkins.build(\"MyProject\", parameters: parameters) { error in\n      if let error = error {\n        print(error)\n        return\n      }\n\n      print(\"Building Job With Paramaters: \\(parameters)\")\n    }\n\n___\n#### Code Coverage\n\nThis client supports retrieving code coverage reports from Jacoco and Cobertura plugins.\n\n    jenkins.coberturaCoverage(project, handler: { report in\n      if let report = report {\n        print(report.ratio(of: CoberturaCodeCoverageElementType.Lines))\n      }\n    })\n\n    jenkins.jacocoCoverage(project, handler: { report in\n      if let report = report {\n        report.ratio(of: JacocoCodeCoverageElementType.LineCoverage)\n      }\n    })\n\n\n___\n\n## Contributing\n\nSee the [contributing](https://github.com/IntrepidPursuits/Jenkins-Swift/blob/master/CONTRIBUTING.md) document for more information. Thank you to all [contributors](https://github.com/IntrepidPursuits/Jenkins-Swift/graphs/contributors).\n___\n\n## License\n\nJenkins-Swift is free software and may be redistributed under the terms specified in the [LICENSE](https://github.com/IntrepidPursuits/Jenkins-swift/blob/master/license.txt) file.\n\n___\n\n## About\n\nJenkins-Swift is maintained by Patrick Butkiewicz and Intrepid Pursuits.\n\n![Intrepid Pursuits](https://avatars1.githubusercontent.com/u/2151424)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintrepidpursuits%2Fjenkins-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintrepidpursuits%2Fjenkins-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintrepidpursuits%2Fjenkins-swift/lists"}