{"id":14008472,"url":"https://github.com/cdancy/jenkins-rest","last_synced_at":"2025-05-15T11:02:58.099Z","repository":{"id":37960798,"uuid":"56113204","full_name":"cdancy/jenkins-rest","owner":"cdancy","description":"Java client, built on top of jclouds, for working with Jenkins REST API ","archived":false,"fork":false,"pushed_at":"2025-02-26T10:17:46.000Z","size":2863,"stargazers_count":395,"open_issues_count":42,"forks_count":177,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-21T18:50:41.153Z","etag":null,"topics":["cd","cdcd","ci","client","continuous-integration","devops","java","jclouds","jenkins","jenkins-rest","rest","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdancy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2016-04-13T02:09:37.000Z","updated_at":"2025-04-10T16:27:09.000Z","dependencies_parsed_at":"2024-01-18T16:23:11.878Z","dependency_job_id":"2e54977d-7b8c-4035-af8e-51fce4e0f8ed","html_url":"https://github.com/cdancy/jenkins-rest","commit_stats":{"total_commits":430,"total_committers":28,"mean_commits":"15.357142857142858","dds":0.8116279069767443,"last_synced_commit":"2e87dfc6df1bdca18b706acc577c142b1a53ffeb"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fjenkins-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fjenkins-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fjenkins-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdancy%2Fjenkins-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdancy","download_url":"https://codeload.github.com/cdancy/jenkins-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"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","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":["cd","cdcd","ci","client","continuous-integration","devops","java","jclouds","jenkins","jenkins-rest","rest","rest-api"],"created_at":"2024-08-10T11:01:42.627Z","updated_at":"2025-05-15T11:02:58.043Z","avatar_url":"https://github.com/cdancy.png","language":"Java","readme":"\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.cdancy/jenkins-rest/badge.png)](https://maven-badges.herokuapp.com/maven-central/io.github.cdancy/jenkins-rest)\n[![Stack Overflow](https://img.shields.io/badge/stack%20overflow-jenkins\u0026#8211;rest-4183C4.svg)](https://stackoverflow.com/questions/tagged/jenkins+rest)\n\n# jenkins-rest\n\nJava client is built on the top of jclouds for working with Jenkins REST API.\n\n## Setup\n\nClient's can be built like so:\n```\nJenkinsClient client = JenkinsClient.builder()\n.endPoint(\"http://127.0.0.1:8080\") // Optional. Defaults to http://127.0.0.1:8080\n.credentials(\"admin:password\") // Optional.\n.build();\n\nSystemInfo systemInfo = client.api().systemApi().systemInfo();\nassertTrue(systemInfo.jenkinsVersion().equals(\"1.642.4\"));\n```\n      \n## Latest release\n\nCan be found in maven like so:\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.cdancy\u003c/groupId\u003e\n  \u003cartifactId\u003ejenkins-rest\u003c/artifactId\u003e\n  \u003cversion\u003eX.Y.Z\u003c/version\u003e\n  \u003cclassifier\u003esources|tests|javadoc|all\u003c/classifier\u003e (Optional)\n\u003c/dependency\u003e\n```\n\n## Documentation\n\n* javadocs can be found via [github pages here](http://cdancy.github.io/jenkins-rest/docs/javadoc/)\n* the [jenkins-rest wiki](https://github.com/cdancy/jenkins-rest/wiki)\n\n## Property based setup\n\nClient instances do NOT need to supply the endPoint or credentials as a part of instantiating the JenkinsClient object. \nInstead one can supply them through system properties, environment variables, or a combination \nof the two. System properties will be searched first and if not found, will attempt to \nquery the environment.\n\nSetting the `endpoint` can be done with any of the following (searched in order):\n\n- `jenkins.rest.endpoint`\n- `jenkinsRestEndpoint`\n- `JENKINS_REST_ENDPOINT`\n\nWhen none is found, the endpoint is set to `http://localhost:8080`.\n\nSetting the `credentials` can be done with any of the following (searched in order):\n\n- `jenkins.rest.api.token`\n- `jenkinsRestApiToken`\n- `JENKINS_REST_API_TOKEN`\n- `jenkins.rest.credentials`\n- `jenkinsRestCredentials`\n- `JENKINS_REST_CREDENTIALS`\n\nWhen none is found, no authentication is used (anonymous).\n\n## Credentials\n\njenkins-rest credentials can take 1 of 3 forms:\n\n- Colon delimited username and api token: __admin:apiToken__\n  - use `JenkinsClient.builder().apiToken(\"admin:apiToken\")`\n- Colon delimited username and password: __admin:password__\n  - use `JenkinsClient.builder().credentials(\"admin:password\")`\n- Base64 encoded username followed by password __YWRtaW46cGFzc3dvcmQ=__ or api token __YWRtaW46YXBpVG9rZW4=__\n  - use `JenkinsClient.builder().credentials(\"YWRtaW46cGFzc3dvcmQ=\")`\n  - use `JenkinsClient.builder().apiToken(\"YWRtaW46YXBpVG9rZW4=\")`\n\nThe Jenkins crumb is automatically requested when POSTing using the anonymous and the username:password authentication methods.\nIt is not requested when you use the apiToken as it is not needed in this case.\nFor more details, see\n\n* [CSRF Protection on jenkins.io](https://www.jenkins.io/doc/book/security/csrf-protection/)\n* [Cloudbees crumb documentation](https://support.cloudbees.com/hc/en-us/articles/219257077-CSRF-Protection-Explained).\n\n## Examples\n\nThe [mock](https://github.com/cdancy/jenkins-rest/tree/master/src/test/java/com/cdancy/jenkins/rest/features) and [live](https://github.com/cdancy/jenkins-rest/tree/master/src/test/java/com/cdancy/jenkins/rest/features) tests provide many examples\nthat you can use in your own code.\n\n## Components\n\n- jclouds \\- used as the backend for communicating with Jenkins REST API\n- AutoValue \\- used to create immutable value types both to and from the jenkins program\n    \n## Testing\n\nRunning mock tests can be done like so:\n\n\t./gradlew clean build mockTest\n\t\nRunning integration tests require an existing jenkins instance which can be obtained with docker:\n\n        docker build -t jenkins-rest/jenkins src/main/docker\n        docker run -d --rm -p 8080:8080 --name jenkins-rest jenkins-rest/jenkins\n\t./gradlew clean build integTest \n\n### Integration tests settings\n\nIf you use the provided docker instance, there is no other preparation necessary.\nIf you wish to run integration tests against your own Jenkins server, the requirements are outlined in the next section.\n\n#### Jenkins instance requirements\n\n- a running instance accessible on http://127.0.0.1:8080 (can be changed in the gradle.properties file)\n- Jenkins security\n  - Authorization: Anyone can do anything (to be able to test the crumb with the anonymous account)\n  - an `admin` user (credentials used by the tests can be changed in the gradle.properties file) with `ADMIN` role (required as the tests install plugins)\n  - [CSRF protection enabled](https://wiki.jenkins.io/display/JENKINS/CSRF+Protection). Not mandatory but [recommended by the Jenkins documentation](https://jenkins.io/doc/book/system-administration/security/#protect-users-of-jenkins-from-other-threats). The lib supports Jenkins instances with our without this protection (see #14)\n- Plugins\n  - [CloudBees Credentials](https://plugins.jenkins.io/cloudbees-credentials): otherwise an http 500 error occurs when accessing\nto http://127.0.0.1:8080/job/test-folder/job/test-folder-1/ `java.lang.NoClassDefFoundError: com/cloudbees/hudson/plugins/folder/properties/FolderCredentialsProvider`\n  - [CloudBees Folder](https://plugins.jenkins.io/cloudbees-folder) plugin installed\n  - [OWASP Markup Formatter](https://plugins.jenkins.io/antisamy-markup-formatter) configured to use `Safe HTML`\n  - [Configuration As Code](https://plugins.jenkins.io/configuration-as-code) plugin installed\n  - [Pipeline](https://plugins.jenkins.io/workflow-aggregator) plugin installed\n\nThis project provides instructions to setup a [pre-configured Docker container](src/main/docker/README.md)\n\n#### Integration tests configuration\n\n- jenkins url and authentication method used by the tests are defined in the `gradle.properties` file\n- by default, tests use the `credentials` (username:password) authentication method but this can be changed to use the API Token. See the `gradle.properties` file.\n\n#### Running integration tests from within your IDE\n\n- the `integTest` gradle task sets various System Properties\n- if you don't want to use gradle as tests runner in your IDE, configure the tests with the same kind of System Properties\n\n\n# Additional Resources\n\n* [Jenkins REST API](http://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API)\n* [Apache jclouds](https://jclouds.apache.org/start/)\n\n","funding_links":[],"categories":["Java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdancy%2Fjenkins-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdancy%2Fjenkins-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdancy%2Fjenkins-rest/lists"}