2013-12-08 23:34:09 +01:00
|
|
|
<?php
|
|
|
|
|
2014-03-26 00:09:51 +01:00
|
|
|
final class HarbormasterPublishFragmentBuildStepImplementation
|
2014-03-26 00:09:21 +01:00
|
|
|
extends HarbormasterBuildStepImplementation {
|
2013-12-08 23:34:09 +01:00
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return pht('Publish Fragment');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getGenericDescription() {
|
|
|
|
return pht('Publish a fragment based on a file artifact.');
|
|
|
|
}
|
|
|
|
|
2015-08-06 13:19:42 +02:00
|
|
|
|
|
|
|
public function getBuildStepGroupKey() {
|
|
|
|
return HarbormasterPrototypeBuildStepGroup::GROUPKEY;
|
|
|
|
}
|
|
|
|
|
2013-12-08 23:34:09 +01:00
|
|
|
public function getDescription() {
|
|
|
|
return pht(
|
2014-03-26 00:10:50 +01:00
|
|
|
'Publish file artifact %s as fragment %s.',
|
|
|
|
$this->formatSettingForDescription('artifact'),
|
|
|
|
$this->formatSettingForDescription('path'));
|
2013-12-08 23:34:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(
|
|
|
|
HarbormasterBuild $build,
|
|
|
|
HarbormasterBuildTarget $build_target) {
|
|
|
|
|
|
|
|
$settings = $this->getSettings();
|
|
|
|
$variables = $build_target->getVariables();
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
$viewer = PhabricatorUser::getOmnipotentUser();
|
2013-12-08 23:34:09 +01:00
|
|
|
|
|
|
|
$path = $this->mergeVariables(
|
|
|
|
'vsprintf',
|
|
|
|
$settings['path'],
|
|
|
|
$variables);
|
|
|
|
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
$artifact = $build_target->loadArtifact($settings['artifact']);
|
|
|
|
$impl = $artifact->getArtifactImplementation();
|
|
|
|
$file = $impl->loadArtifactFile($viewer);
|
2013-12-08 23:34:09 +01:00
|
|
|
|
|
|
|
$fragment = id(new PhragmentFragmentQuery())
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
->setViewer($viewer)
|
2013-12-08 23:34:09 +01:00
|
|
|
->withPaths(array($path))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if ($fragment === null) {
|
|
|
|
PhragmentFragment::createFromFile(
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
$viewer,
|
2013-12-08 23:34:09 +01:00
|
|
|
$file,
|
|
|
|
$path,
|
|
|
|
PhabricatorPolicies::getMostOpenPolicy(),
|
|
|
|
PhabricatorPolicies::POLICY_USER);
|
|
|
|
} else {
|
2014-06-09 20:36:49 +02:00
|
|
|
if ($file->getMimeType() === 'application/zip') {
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
$fragment->updateFromZIP($viewer, $file);
|
2013-12-08 23:34:09 +01:00
|
|
|
} else {
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
$fragment->updateFromFile($viewer, $file);
|
2013-12-08 23:34:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 00:02:34 +01:00
|
|
|
public function getArtifactInputs() {
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
'name' => pht('Publishes File'),
|
|
|
|
'key' => $this->getSetting('artifact'),
|
Add `harbormaster.createartifact`
Summary:
Ref T8659. In the general case, this eventually allows build processes to do things like:
- Upload build results (like a ".app" or ".exe" or other binary).
- Pass complex results between build steps (e.g., build step A does something hard and build step B uses it to do something else).
Today, we're a long way away from having the infrastructure for that. However, it is useful to let third party build processes (like Jenkins) upload URIs that link back to the external build results.
This adds `harbormaster.createartifact` so they can do that. The only useful thing to do with this method today is have your Jenkins build do this:
params = array(
"uri": "https://jenkins.mycompany.com/build/23923/details/",
"name": "View Build Results in Jenkins",
"ui.external": true,
);
harbormaster.createartifact(target, 'uri', params);
Then (after the next diff) we'll show a link in Differential and a prominent link in Harbormaster. I didn't actually do the UI stuff in this diff since it's already pretty big.
This change moves a lot of code around, too:
- Adds PHIDs to artifacts.
- It modularizes build artifact types (currently "file", "host" and "URI").
- It formalizes build artifact parameters and construction:
- This lets me generate usable documentation about how to create artifacts.
- This prevents users from doing dangerous or policy-violating things.
- It does some other general modernization.
Test Plan:
{F715633}
{F715634}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T8659
Differential Revision: https://secure.phabricator.com/D13900
2015-08-15 16:28:56 +02:00
|
|
|
'type' => HarbormasterFileArtifact::ARTIFACTCONST,
|
2014-03-26 00:02:34 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-26 00:08:40 +01:00
|
|
|
public function getFieldSpecifications() {
|
2013-12-08 23:34:09 +01:00
|
|
|
return array(
|
|
|
|
'path' => array(
|
2014-03-26 00:08:40 +01:00
|
|
|
'name' => pht('Path'),
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
),
|
2013-12-08 23:34:09 +01:00
|
|
|
'artifact' => array(
|
2014-03-26 00:08:40 +01:00
|
|
|
'name' => pht('File Artifact'),
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
|
|
|
),
|
|
|
|
);
|
2013-12-08 23:34:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|