Need to publish a file url as an artifact
Hi,
I am new to Teamcity and trying to integrate and run my test suite ( a bunch of shell scripts) from it. I am trying to publish, as the artifact my test plan in case i have a failure, using this: -
echo "##teamcity[publishArtifacts '$testPath']" where, $testPath is of the form http://<file_location>
Teamcity picks up the path alright, but presumably tries to find a file of the same name within the root artifacts directory, and fails.
Please suggest how can I make Teamcity understand that I want to publish a file as a url link.
Thanks.
Please sign in to leave a comment.
Can you copy the file to a local dir and then use your artifact service message?
I wouldn't like to do that at the first place, but would like to publish artifacts pointing to a remote server url.
Can you please help me with that implementation.
If there's no workaround, I guess we can only do it the way you've said in your post.
Thanks,
Avijit
Avijit,
Are you trying to achive something like: http://jetbrains.net/tracker/issue/TW-1558 ?
The service message you noted is aimed at publishing a file on the build agent to TeamCity server as an artifact of a currently running build. Given this, the service message takes path to a local file as a parameter and uploads the file to the TeamCIty server, no server URL is necessary.
Can you please detail what task are you trying to perform within your build script and what kind of output it generates?
I am trying to point to my testplan as an artifact in case any of my testcase fails. The code goes something like this: -
if [ $testReturnCode -ne 0 ]; then
## Test failed code
echo "##teamcity[testFailed name='$i' message='Test $tmp failed' details='Test $tmp failed']" $tmp -> testcase number
echo "##teamcity[publishArtifacts '$testPlan']" $testPlan -> of form http://<testplan_location>
...
fi
What I understand from your mail is that the testplan needs to reside in the build agent path for teamcity to pick up and upload to the server, and that it cannot publish something which doesn't reside in its path. Is that the case?
Thanks,
Avijit
Avijit,
What is testplan in your case? Is it a file?
You are right, to publish a file as build's artifact it should be presend on the agent's file system.
Hi Yegor,
Yes, you are right... my tesplan is a html doc remotely located, accessible over http. Anyways, I wouldn't like to import it to the local server to publish it through teamcity.
Hence, I guess I'll have to send the link somewhere in the log files I'm generating and publishing through my scripts.
This brings me to another question: -
I'm trying to use this code: -
echo "##teamcity[testStarted name='test1']"
if <test_failed condition> then
echo "##teamcity[testFailed name=''test1' message='Test 1 failed' details='log/1.log']"
fi
echo "##teamcity[testFinished name='test1']"
to publish my logs as a stack trace in case my test case fails. But it looks like teamcity doesn't accept a file for the 'details' parameter.
Next I tried to read the file content to a variable with a `cat log/1.log` and then pass that variable to 'details'... however, that didn't work either.
Please help.
Avijit,
We have a feature request filed to allo custom test run data. You can vote for it if you like: TW-7647
"details" attribute of "testFailed" message takes text (String). If you pass text as described in the documentation it should work. To debug your issue you can probably try to send simple text. If that does not work please send us the output that your build generates including the service messages as they are printed into the console and the results you get in TeamCity.
As a temporary workaround, why not have a simple .html file with a link to the url that you can then publish? Better yet, let it redirect and you're all set.
Something like this maybe?
<html>
<head>
<meta http-equiv="REFRESH" content="4;url=http://remote/path/to/testplan.html"/>
</head>
<body>
This page will automatically redirect you to the <a href="http://remote/path/to/testplan.html">testplan</a>
</body>
</html>
Hello Ray,
I think your solution is perfect as per my requirement. This can be used as a good workaround for what I am planning to do.
Thanks for your help.
- Avijit
I'd also like to provide links to externally hosted files within the artefacts page.
As a special case, I'd like some items to show up in multiple places in the artefacts tree, but I don't want to store the item multiple times.
Hi Rob
Could you share examples with us - what kind of files do you need to publish in such way?
Michael
It's mostly a convenience thing.The aim here is to reduce the amount of duplicate data stored as artefacts.
Some specific examples:
* Dependencies on 3rd party and internal components that never change. Every build contains these components - so we are storing duplicates over and over again.
* Links to documentation that's already stored elsewhere
* Allow an artefact to be listed twice in the TeamCity artefacts page, but only stored once. This is so it can be stored both in its normal place in the artefact heirarchy (generally buried), and also at the top level.
More detail on the last example. Our artefacts tree currently looks like this:
Root
|_ Product
|_ <product heirarchy, including the built installer about 3 levels down>
|_ Deliverables
|_ Installer
That is, we currently archive the Installer twice, simply to get the convenience of a top level link in the artefacts tree.
Hi Rob
Sorry for late response.
We want to keep an original meaning of build artifact list - unique files generated within the build, and stored together in our repository.
Your goal is a bit different.
As suggested above, you can generate this list on a special HTML-page, and publish it right in build results as additional tab.