tag:help.appveyor.com,2012-11-13:/discussions/suggestions/1846-create-environment-variables-for-project-build-and-repository-urlsAppVeyor: Discussion 2018-10-19T08:18:27Ztag:help.appveyor.com,2012-11-13:Comment/431870062017-08-10T19:54:09Z2017-08-10T19:54:11ZCreate environment variables for project, build, and repository URLs<div><p>Please add three new environment variables:</p>
<ul>
<li><code>APPVEYOR_PROJECT_URI</code>: the URI to the project</li>
<li><code>APPVEYOR_BUILD_URI</code>: the URI to the build results for the current build</li>
<li><code>APPVEYOR_REPO_URI</code>: the URI to the source control repository; the URI used to clone the repository.</li>
</ul>
<p>Right now, I have some automation in place that needs this, and I have to construct these based on the other <code>APPVEYOR</code> environment variables:</p>
<pre>
<code>$accountName = Get-EnvironmentVariable 'APPVEYOR_ACCOUNT_NAME'
$projectSlug = Get-EnvironmentVariable 'APPVEYOR_PROJECT_SLUG'
$projectUri = 'https://ci.appveyor.com/project/{0}/{1}' -f $accountName,$projectSlug
$buildVersion = Get-EnvironmentVariable 'APPVEYOR_BUILD_VERSION'
$buildUri = '{0}/build/{1}' -f $projectUri,$buildVersion
$buildInfo.BuildUri = $buildUri
$buildInfo.JobUri = $projectUri
$baseUri = ''
switch( (Get-EnvironmentVariable 'APPVEYOR_REPO_PROVIDER') )
{
'gitHub'
{
$baseUri = 'https://github.com'
}
default
{
Write-Error -Message ('Unsupported AppVeyor source control provider ''{0}''. If you''d like us to add support for this provider, please submit a new issue at https://github.com/webmd-health-services/Whiskey/issues. Copy/paste your environment variables from this build''s output into your issue.' -f $_)
}
}
$repoName = Get-EnvironmentVariable 'APPVEYOR_REPO_NAME'
$buildInfo.ScmUri = '{0}/{1}.git' -f $baseUri,$repoName</code>
</pre></div>splatteredbits