Skip to content

Commit cb5f701

Browse files
committed
Initial commit
0 parents  commit cb5f701

File tree

6 files changed

+323
-0
lines changed

6 files changed

+323
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
.idea/
3+
.DS_Store

bin/jenkins

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require_once __DIR__ . '/../vendor/autoload.php';
5+
6+
use Symfony\Component\Console\Application;
7+
8+
$app = new Application();
9+
$app->add(new \Idnan\Jenkins\DeployCommand());
10+
$app->run();

composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "idnan/jenkins-deploy",
3+
"description": "A jenkins cli tool to run jobs from command line",
4+
"type": "project",
5+
"authors": [
6+
{
7+
"name": "Adnan Ahmed",
8+
"email": "idnan.se@gmail.com"
9+
}
10+
],
11+
"require": {
12+
"symfony/console": "^4.2"
13+
},
14+
"autoload": {
15+
"psr-4": {
16+
"Idnan\\Jenkins\\": "./src/"
17+
}
18+
},
19+
"license": ""
20+
}

composer.lock

Lines changed: 214 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Idnan\Jenkins;
4+
5+
use Symfony\Component\Console\Command\Command as SymfonyCommand;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
/**
10+
* Class Command
11+
*
12+
* @package Idnan\Jenkins
13+
*/
14+
abstract class Command extends SymfonyCommand
15+
{
16+
/** @var InputInterface $input */
17+
protected $input;
18+
19+
/** @var OutputInterface $output */
20+
protected $output;
21+
22+
/**
23+
* @param \Symfony\Component\Console\Input\InputInterface $input
24+
* @param \Symfony\Component\Console\Output\OutputInterface $output
25+
*
26+
* @return void
27+
*/
28+
public function execute(InputInterface $input, OutputInterface $output)
29+
{
30+
$this->input = $input;
31+
$this->output = $output;
32+
33+
$this->process();
34+
}
35+
36+
/**
37+
* Runs the command.
38+
*
39+
* @return void
40+
*/
41+
public abstract function process();
42+
}

src/DeployCommand.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Idnan\Jenkins;
4+
5+
use Symfony\Component\Console\Input\InputArgument;
6+
7+
/**
8+
* Class DeployCommand
9+
*
10+
* @package Idnan\Jenkins
11+
*/
12+
class DeployCommand extends Command
13+
{
14+
15+
/**
16+
* Configures the current command.
17+
*/
18+
public function configure()
19+
{
20+
$this->setName('run')
21+
->setDescription('Run the specified job in jenkins')
22+
->addArgument('job', InputArgument::REQUIRED, 'Job name');
23+
}
24+
25+
/**
26+
* Runs the command.
27+
*
28+
* @return void
29+
*/
30+
public function process()
31+
{
32+
echo $this->input->getArgument('job');
33+
}
34+
}

0 commit comments

Comments
 (0)