@param string $buildId
@param string $buildPath
@param string $repoReference

@throws Exception\RuntimeException if app skeleton has not yet been installed
196338
public function deployCode(
        string $buildId = null,
        string $buildPath = null,
        string $repoReference = null
    ): void {
        if (!($buildId || $repoReference)) {
            throw new Exception\BadMethodCallException('$buildId or $repoReference must be set.');
        }

        if ($buildId) {
            $this->deployFromBuild($buildId, $buildPath);
        } else {
            $this->deployFromRepo($repoReference);
        }
    }
367356
public function main()
    {
        if ($this->function === null && $this->expression === null) {
            throw new BuildException(
                "You must specify a function to execute or PHP expression to evalute.",
                $this->getLocation()
            );
        }

        if ($this->function !== null && $this->expression !== null) {
            throw new BuildException("You can specify function or expression, but not both.", $this->getLocation());
        }

        if ($this->expression !== null && !empty($this->params)) {
            throw new BuildException(
                "You cannot use nested <param> tags when evaluationg a PHP expression.",
                $this->getLocation()
            );
        }

        if ($this->function !== null) {
            $this->callFunction();
        } elseif ($this->expression !== null) {
            $this->evalExpression();
        }
    }
606907
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }

        $client = $this->getGitClient();
        $client->initRepository($this->isBare());

        $msg = 'git-init: initializing '
            . ($this->isBare() ? '(bare) ' : '')
            . '"' . $this->getRepository() . '" repository';
        $this->log($msg, Project::MSG_INFO);
    }
452312
public function preBuild()
    {
        $build_path = $this->getBuildPath();

        if ($build_path) {
            if (is_dir($build_path)) {
                $build_path = rtrim($build_path, DIRECTORY_SEPARATOR);

                if (!is_dir("$build_path/Manager/Base")) {
                    $old_umask = umask(0);
                    $dir_created = mkdir("$build_path/Manager/Base");
                    umask($old_umask);

                    if ($dir_created) {
                        $this->triggerEvent('on_dir_created', ["$build_path/Manager/Base"]);
                    } else {
                        throw new RuntimeException("Failed to create '$build_path/Manager/Base' directory");
                    }
                }
            } else {
                throw new InvalidArgumentException("Directory '$build_path' not found");
            }
        }
    }
209317
public void setClasspathRef(Reference r) {
        Path path = createClasspath();
        path.setRefid(r);
        path.toString(); // Evaluated for its side-effects (throwing a
        // BuildException)
    }
1350534
protected static function initWrite($buildfilePath)
    {
        // Overwriting protection
        if (file_exists($buildfilePath)) {
            throw new ConfigurationException('Cannot overwrite existing file.');
        }

        $content = '<?xml version="1.0" encoding="UTF-8" ?>' . PHP_EOL;
        $content .= '' . PHP_EOL;
        $content .= '<project name="" description="" default="">' . PHP_EOL;
        $content .= '    ' . PHP_EOL;
        $content .= '    <target name="" description="">' . PHP_EOL;
        $content .= '        ' . PHP_EOL;
        $content .= '    </target>' . PHP_EOL;
        $content .= '    ' . PHP_EOL;
        $content .= '</project>' . PHP_EOL;

        file_put_contents($buildfilePath, $content);
    }
969756
function(buildPath, manifest) {
    fs.stat(manifest, function(err, stat) {
        if (! err) {
            manifest = JSON.parse(fs.readFileSync(manifest));

            for (var key in manifest) {
                del.sync(buildPath + '/' + manifest[key], { force: true });
            }
        }
    });
}
184304
@SuppressWarnings({"PMD.NPathComplexity"})
	/*package*/ URI buildUri(final String rawUrl, final String branch, final String lastKnownCommit) throws URISyntaxException {
		URIBuilder builder = new URIBuilder();
		
		/*
		 * Examples:
		 * 
		 * ssh://git@company.com/project/repository.git
		 * https://username@company.com/scm/project/repository.git
		 * ssh://git@company.com/~username/repository.git
		 * https://username@company.com/scm/~username/repository.git
		 * 
		 */
		
		String repoUrlRaw = rawUrl;
		String repoUrlProcessed = repoUrlRaw;
		
		if (repoUrlProcessed.endsWith(".git")) {
			repoUrlProcessed = repoUrlProcessed.substring(0, repoUrlProcessed.lastIndexOf(".git"));
		}
		
		URI uri = URI.create(repoUrlProcessed.replaceAll(" ", "%20"));
		
		String host = uri.getHost();
		String scheme = "ssh".equalsIgnoreCase(uri.getScheme())? "https" : uri.getScheme();
		int port = uri.getPort();
		String path = uri.getPath();
		if ((path.startsWith("scm/") || path.startsWith("/scm")) && path.length() > 4) {
			path = path.substring(4);
		}
		if (path.length() > 0 && path.charAt(0) == '/') {
			path = path.substring(1, path.length());
		}
		
		String[] splitPath = path.split("/");
		String projectKey = "";
		String repositorySlug = "";
		
		if (splitPath.length > 1) {
			projectKey = splitPath[0];
			repositorySlug = path.substring(path.indexOf('/') + 1, path.length());
		} else {
			// Shouldn't get to this case
			projectKey = "";
			repositorySlug = path;
		}
		
		String apiPath = settings.getApi() != null? settings.getApi() : "";
		
		if (apiPath.endsWith("/")) {
			apiPath = settings.getApi().substring(0, settings.getApi().length() - 1);
		}
		
		builder.setScheme(scheme);
		builder.setHost(host);
		if (port != -1) {
			builder.setPort(port);
		}
		
		builder.setPath(apiPath + "/projects/" + projectKey + "/repos/" + repositorySlug + "/commits");
		if (branch == null || branch.length() == 0) {
			builder.addParameter("until", "master");
		} else {
			builder.addParameter("until", branch.replaceAll(" ", "%20"));
		}
		
		if (lastKnownCommit != null && lastKnownCommit.length() > 0) {
			builder.addParameter("since", lastKnownCommit);
		}
		
		if (settings.getPageSize() > 0) {
			builder.addParameter("limit", String.valueOf(settings.getPageSize()));
		}
		
		return builder.build();
	}
12121
public void execute() throws Exception {
        final var jsonFile = new File(buildDir, "classes/java/main/META-INF/spring-configuration-metadata.json");
        if (!jsonFile.exists()) {
            throw new RuntimeException("Could not locate file " + jsonFile.getCanonicalPath());
        }
        final var mapper = new ObjectMapper().findAndRegisterModules();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);

        final TypeReference<Map<String, Set<ConfigurationMetadataProperty>>> values = new TypeReference<>() {
        };
        final Map<String, Set> jsonMap = mapper.readValue(jsonFile, values);
        final Set<ConfigurationMetadataProperty> properties = jsonMap.get("properties");
        final Set<ConfigurationMetadataProperty> groups = jsonMap.get("groups");

        final Set<ConfigurationMetadataProperty> collectedProps = new HashSet<>();
        final Set<ConfigurationMetadataProperty> collectedGroups = new HashSet<>();

        properties.stream()
            .filter(p -> NESTED_TYPE_PATTERN.matcher(p.getType()).matches())
            .forEach(Unchecked.consumer(p -> {
                final var matcher = NESTED_TYPE_PATTERN.matcher(p.getType());
                final var indexBrackets = matcher.matches();
                final var typeName = matcher.group(1);
                final var typePath = ConfigurationMetadataClassSourceLocator.buildTypeSourcePath(this.sourcePath, typeName);

                final var parser = new ConfigurationMetadataUnitParser(this.sourcePath);
                parser.parseCompilationUnit(collectedProps, collectedGroups, p, typePath, typeName, indexBrackets);
            }));

        properties.addAll(collectedProps);
        groups.addAll(collectedGroups);

        final var hints = processHints(properties, groups);

        processNestedEnumProperties(properties, groups);

        jsonMap.put("properties", properties);
        jsonMap.put("groups", groups);
        jsonMap.put("hints", hints);

        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        final var pp = new MinimalPrettyPrinter();
        final var writer = mapper.writer(pp);
        writer.writeValue(jsonFile, jsonMap);
    }
238843
protected function handleBareRepository(Builder $builder, $reference, $buildPath)
    {
        $gitConfig = parse_ini_file($reference.'/config', true);

        // If it is indeed a bare repository, then extract it into our build path:
        if ($gitConfig['core']['bare']) {
            $cmd = 'mkdir %2$s; git --git-dir="%1$s" archive %3$s | tar -x -C "%2$s"';
            $builder->executeCommand($cmd, $reference, $buildPath, $this->getBranch());
            return true;
        }

        return false;
    }
933403
public function main()
    {
        if (null === $this->getRepository() && false === $this->getRemoteRepo()) {
            throw new BuildException('"repository" is required parameter');
        }

        if (null === $this->getTreeish()) {
            throw new BuildException('"treeish" is required parameter');
        }

        $cmd = $this->getGitClient(false, $this->getRepository() !== null ? $this->getRepository() : './')
            ->getCommand('archive')
            ->setOption('prefix', $this->prefix)
            ->setOption('output', $this->output !== null ? $this->output->getPath() : false)
            ->setOption('format', $this->format)
            ->setOption('remote', $this->remoteRepo)
            ->addArgument($this->treeish);

        $this->log('Git command : ' . $cmd->createCommandString(), Project::MSG_DEBUG);

        $cmd->execute();

        $msg = 'git-archive: archivating ' . '"' . $this->getRepository() . '" repository (' . $this->getTreeish() . ')';
        $this->log($msg, Project::MSG_INFO);
    }
1115654
public void addRepository(UpdateRepository newRepo) {
        for (UpdateRepository ur : repositories) {
            if (ur.getId().equals(newRepo.getId())) {
                throw new RuntimeException("Repository with id " + newRepo.getId() + " already exists");
            }
        }
        newRepo.refresh();
        repositories.add(newRepo);
    }
200767
private void initializeRetireJsRepo(Settings settings, URL repoUrl) throws UpdateException {
        try {
            final File dataDir = settings.getDataDirectory();
            final File tmpDir = settings.getTempDirectory();
            boolean useProxy = false;
            if (null != settings.getString(Settings.KEYS.PROXY_SERVER)) {
                useProxy = true;
                LOGGER.debug("Using proxy");
            }
            LOGGER.debug("RetireJS Repo URL: {}", repoUrl.toExternalForm());
            final URLConnectionFactory factory = new URLConnectionFactory(settings);
            final HttpURLConnection conn = factory.createHttpURLConnection(repoUrl, useProxy);
            final String filename = repoUrl.getFile().substring(repoUrl.getFile().lastIndexOf("/") + 1, repoUrl.getFile().length());
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                final File tmpFile = new File(tmpDir, filename);
                final File repoFile = new File(dataDir, filename);
                try (InputStream inputStream = conn.getInputStream();
                        FileOutputStream outputStream = new FileOutputStream(tmpFile)) {
                    IOUtils.copy(inputStream, outputStream);
                }
                //using move fails if target and destination are on different disks which does happen (see #1394 and #1404)
                Files.copy(tmpFile.toPath(), repoFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
                if (!tmpFile.delete()) {
                    tmpFile.deleteOnExit();
                }
            }
        } catch (IOException e) {
            throw new UpdateException("Failed to initialize the RetireJS repo", e);
        }
    }
608245
public static void saveBuildInfo(BuildInfo buildInfo, FilePath ws, Run build, Log logger) throws Exception {
        String jobBuildNumber = BuildUniqueIdentifierHelper.getBuildNumber(build);
        String buildInfoId = createBuildInfoId(build, buildInfo.getName(), buildInfo.getNumber());

        BuildDataFile buildDataFile = new BuildDataFile(BuildInfoStep.STEP_NAME, buildInfoId);
        buildDataFile.putPOJO(buildInfo);
        writeBuildDataFile(ws, jobBuildNumber, buildDataFile, logger);
    }
1120819
public function getDocumentRoot(string $buildId = null): ?string
    {
        $documentRoot = $this->getCodePath($buildId);

        if ($this->getRelativeDocumentRoot()) {
            $documentRoot .= '/' . $this->getRelativeDocumentRoot();
        }

        return $documentRoot;
    }
1206271
public function run(string $buildVersion, bool $createZipFile = true) : void
    {
        $this->logger->info('Resource folder: ' . $this->resourceFolder . '');
        $this->logger->info('Build folder: ' . $this->buildFolder . '');

        Helper\BuildHelper::run(
            $buildVersion,
            $this->resourceFolder,
            $this->logger,
            $this->writerCollection,
            $this->dataCollectionFactory,
            $this->collectPatternIds
        );

        if (!$createZipFile) {
            return;
        }

        $this->logger->info('started creating the zip archive');

        $zip = new ZipArchive();
        $zip->open($this->buildFolder . '/browscap.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);

        $files = [
            'full_asp_browscap.ini',
            'full_php_browscap.ini',
            'browscap.ini',
            'php_browscap.ini',
            'lite_asp_browscap.ini',
            'lite_php_browscap.ini',
            'browscap.xml',
            'browscap.csv',
            'browscap.json',
        ];

        foreach ($files as $file) {
            $filePath = $this->buildFolder . '/' . $file;

            if (!file_exists($filePath) || !is_readable($filePath)) {
                continue;
            }

            $zip->addFile($filePath, $file);
        }

        $zip->close();

        $this->logger->info('finished creating the zip archive');
    }
672504
public function main(){
        
        if(is_null($this->getDomain())){
            throw new \BuildException('the domain property is required');
        }

        if(is_null($this->getName())){
            throw new \BuildException('the name property is required');
        }

        if(is_null($this->getVersion())){
            throw new \BuildException('the version property is required');
        }

        if(is_null($this->getTasklist())){
            throw new \BuildException('the tasklist property is required');
        }

        try {
            $workflow = $this->getService()->describeWorkflowType([
                'domain' => $this->getDomain(),
                'workflowType' => [
                    'name' => $this->getName(),
                    'version' => $this->getVersion()
                ]
            ]);

            if ($workflow->get('typeInfo')['status'] != 'REGISTERED') {
                throw new \BuildException('the workflow "' . $this->getName() . '" is no more available');
            }

            $this->log('The workflow "' . $this->getName() . '" already exists');
        } catch (SwfException $e) {
            $this->log('Creating "' . $this->getName() . '" v.' . $this->getVersion() . ' workflow');

            $params = [
                'domain' => $this->getDomain(),
                'name' => $this->getName(),
                'version' => $this->getVersion(),
                'description' => $this->getDescription(),
                'defaultTaskStartToCloseTimeout' => $this->getTaskStartToCloseTimeout() ?: 'NONE',
                'defaultExecutionStartToCloseTimeout' => $this->getExecutionStartToCloseTimeout() ?: 'NONE',
                'defaultTaskList' => [
                    'name' => $this->getTasklist()
                ]
            ];

            if ($this->getChildPolicy()) {
                $params['defaultChildPolicy'] = $this->getChildPolicy();
            }

            $this->getService()->registerWorkflowType($params);

            $this->log('"' . $this->getName() . '" v.' . $this->getVersion() . ' workflow successfully created');
        }
    }