-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: update the page docs and update ci config
- Loading branch information
Showing
6 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Jenkins client | ||
|
||
[![License](https://img.shields.io/github/license/phppkg/jenkins-client?style=flat-square)](LICENSE) | ||
[![Php Version](https://img.shields.io/packagist/php-v/phppkg/jenkins-client?maxAge=2592000)](https://packagist.org/packages/phppkg/jenkins-client) | ||
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/phppkg/jenkins-client)](https://github.com/phppkg/jenkins-client) | ||
[![Actions Status](https://github.com/phppkg/jenkins-client/workflows/Unit-Tests/badge.svg)](https://github.com/phppkg/jenkins-client/actions) | ||
|
||
> **[EN README](README.md)** | ||
`jenkins-client` - 简单方便的使用 API 与 Jenkins CI 进行交互。 | ||
|
||
> `phppkg/jenkins-client` is inspired from the https://github.com/jenkins-khan/jenkins-php-api | ||
## 安装 | ||
|
||
- Required PHP 8.0+ | ||
|
||
**composer** | ||
|
||
```bash | ||
composer require phppkg/jenkins-client | ||
``` | ||
|
||
## 开始使用 | ||
|
||
Before anything, you need to instantiate the client : | ||
|
||
```php | ||
$jenkins = new \PhpPkg\JenkinsClient\Jenkins('http://host.org:8080'); | ||
``` | ||
|
||
If your Jenkins needs authentication, you need to pass a URL like this : `'http://user:token@host.org:8080'`. | ||
|
||
Simple example - sending "String Parameters": | ||
|
||
```shell | ||
curl JENKINS_URL/job/JOB_NAME/buildWithParameters \ | ||
--user USER:TOKEN \ | ||
--data id=123 --data verbosity=high | ||
``` | ||
|
||
Another example - sending a "File Parameter": | ||
|
||
```shell | ||
curl JENKINS_URL/job/JOB_NAME/buildWithParameters \ | ||
--user USER:PASSWORD \ | ||
--form FILE_LOCATION_AS_SET_IN_JENKINS=@PATH_TO_FILE | ||
``` | ||
|
||
Here are some examples of how to use it: | ||
|
||
### Get the color of the job | ||
|
||
```php | ||
$job = $jenkins->getJob("dev2-pull"); | ||
vdump($job->getColor()); | ||
//string(4) "blue" | ||
``` | ||
|
||
### Launch a Job | ||
|
||
```php | ||
$job = $jenkins->launchJob("clone-deploy"); | ||
vdump($job); | ||
// bool(true) if successful or throws a RuntimeException | ||
``` | ||
|
||
### List the jobs of a given view | ||
|
||
```php | ||
$view = $jenkins->getView('madb_deploy'); | ||
foreach ($view->getJobs() as $job) { | ||
var_dump($job->getName()); | ||
} | ||
//string(13) "altlinux-pull" | ||
//string(8) "dev-pull" | ||
//string(9) "dev2-pull" | ||
//string(11) "fedora-pull" | ||
``` | ||
|
||
### List builds and their status | ||
|
||
```php | ||
$job = $jenkins->getJob('dev2-pull'); | ||
foreach ($job->getBuilds() as $build) { | ||
var_dump($build->getNumber()); | ||
var_dump($build->getResult()); | ||
} | ||
//int(122) | ||
//string(7) "SUCCESS" | ||
//int(121) | ||
//string(7) "FAILURE" | ||
``` | ||
|
||
### Check if Jenkins is available | ||
|
||
```php | ||
var_dump($jenkins->isAvailable()); | ||
//bool(true); | ||
``` | ||
|
||
For more information, see the [Jenkins API](https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API). | ||
|
||
## License | ||
|
||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang=""> | ||
<head> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css"> | ||
<title>Jenkins-client - 💪 Designed to interact with Jenkins CI using its API</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script> | ||
window.$docsify = { | ||
repo: 'phppkg/jenkins-client', | ||
maxLevel: 3, | ||
// 加载 _navbar.md | ||
// loadNavbar: true, | ||
loadNavbar: 'test/_navbar.md', | ||
// 加载 _sidebar.md | ||
// loadSidebar: true, | ||
} | ||
</script> | ||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" | ||
bootstrap="test/bootstrap.php" colors="false" convertErrorsToExceptions="true" convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
|
||
<testsuites> | ||
<testsuite name="Library Test Suite"> | ||
<directory>test/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">app</directory> | ||
</whitelist> | ||
</filter> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="test/bootstrap.php" colors="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="Library Test Suite"> | ||
<directory>test/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">app</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
* [English](/README.md) | ||
* [中文说明](/README.zh-CN.md) | ||
* **[PHPPkg](https://github.com/phppkg)** | ||
* [Config](https://phppkg.github.io/config/ "🗂 Config load, management, merge, get, set and more.") | ||
* [EasyTpl](https://phppkg.github.io/easytpl/ "⚡️ Simple and fastly template engine for PHP") | ||
* [Http-client](https://phppkg.github.io/http-client/ "An easy-to-use HTTP client library for PHP") | ||
* [PhpGit](https://phppkg.github.io/phpgit/ "A Git wrapper library for PHP") | ||
* [Ini](https://phppkg.github.io/ini/ "💪 An enhanced INI format parser written in PHP") | ||
* [Jenkins-client](https://phppkg.github.io/jenkins-client/ "Designed to interact with Jenkins CI using its API") | ||
* [Console](https://inhere.github.io/php-console/ "🖥 PHP CLI library, provide console options, arguments parse") | ||
* [Validate](https://inhere.github.io/php-validate/ "php data validate engine") | ||
* **[Toolkit](https://github.com/php-toolkit)** | ||
* [PFlag](https://php-toolkit.github.io/pflag/ "console option and argument parse") | ||
* [Stdlib](https://php-toolkit.github.io/stdlib/ "Useful basic tools library for PHP development.") |