Skip to content

Commit

Permalink
up: update the page docs and update ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 11, 2023
1 parent bc4089b commit 19567d9
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.0, 8.1] # 7.2, 7.3,
php: [8.0, 8.1, 8.2] # 7.2, 7.3,
# os: [ubuntu-latest] # macOS-latest, windows-latest,
# include: # will not testing on php 7.2
# - os: 'ubuntu-latest'
Expand Down Expand Up @@ -53,4 +53,4 @@ jobs:
run: composer update --no-progress

- name: Run test suite
run: phpunit --debug
run: phpunit
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[![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)

`jenkins-client` is a set of classes designed to interact with Jenkins CI using its API.
> **[中文说明](README.zh-CN.md)**
`jenkins-client` - Designed to interact with Jenkins CI using its API.

> `phppkg/jenkins-client` is inspired from the https://github.com/jenkins-khan/jenkins-php-api
Expand Down
106 changes: 106 additions & 0 deletions README.zh-CN.md
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)
25 changes: 25 additions & 0 deletions index.html
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>
27 changes: 12 additions & 15 deletions phpunit.xml
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>
14 changes: 14 additions & 0 deletions test/_navbar.md
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.")

0 comments on commit 19567d9

Please sign in to comment.