How do I get Travis-CI to show build artifacts? - continuous-integration

I have added Travic-CI on travis-ci.org to my github project.
The .travis.yml file looks like this:
language: csharp
solution: MyProject.sln
So, when I go to
https://travis-ci.org/username/MyProject/builds/somenumber
, then it shows the build as passing.
I can also see the log-file, but I can nowhere see the the files generated (the .exe).
Do I have to add anything to .travis.yml so it displays/publishes my .exe as artifact on my project's page on travis-ci.org ?
Or do I have to flip a switch somewhere else ?
Or is Travis not thought to do this ?
Note:
Show the executable on travis-ci.org (so I can link to it from github), not publishing it automagically as release to github, althought that would be fine, too.

By default, the build artifacts are thrown away with the machine. What counts is the build and test result. If you want to retain some or all build artifacts, have a look at the deploy options: https://docs.travis-ci.com/user/deployment/

Travis now offers a built-in option to upload build artifacts to AWS: https://docs.travis-ci.com/user/uploading-artifacts/. To set it up you just have to enable the add-on and provide some configuration:
For a minimal configuration, add the following to your .travis.yml:
addons:
artifacts: true
and add the following environment variables in the repository
settings:
ARTIFACTS_KEY=(AWS access key id)
ARTIFACTS_SECRET=(AWS secret access key)
ARTIFACTS_BUCKET=(S3 bucket name)

Related

Pass/share parameter values between dependant builds in TeamCity

Setup: Build CD has has Artifact Dependency and Snapshot Dependency on Build CI. Build CI pulls from VCS root and generates artifacts for Build CD.
Problem: In Build CD I need %teamcity.build.branch% parameter, but it's not available, because it only uses artifacts and has no VCS Roots linked.
Question: Is there a way to pass parameters between dependant builds? (search results in the googles seem of topic)
Workaround 1: I can access %teamcity.build.branch% in Build CD if I link it to same VCS root Build CI is using, but I'd like to avoid having this link and Build CD unnecessarily pulling from VCS (build log shows it does this).
Workaround 2: I could write parameter to a file in Build CI and read from it in Build CD later. This is a hack and I would like to avoid it as well.
Absolutely. In CD, add a parameter called whatever, with value equal to %dep.Build_CI.teamcity.build.branch%. TeamCity will help you figure out the exact value thanks to its auto-suggestion/auto-completion, once you type %dep..

Appveyor builds for all branches instead of specified ones

We have currently three separated appveyor projects, one for each branch in our repository.
Our problem is follwing:
Appveyor ignores my filter on github branches. Everytime we make a commit to master, stage or dev it builds on all three projects instead of the single one we did make a commit to.
Each branch has a unique appveyor.yml file looking like this:
This is the appveyor.yml for dev
version: 0.0.{build}
branches:
only:
- dev
image: Visual Studio 2017
configuration: dev
before_build:
- nuget restore
build:
project: Core.Api.sln
publish_wap: true
verbosity: minimal
build_script:
- ps: .\build.ps1
after_build:
- cmd: dotnet publish src\Core.Api --output %appveyor_build_folder%\dist
test: off
artifacts:
- path: dist
name: dist.web
deploy:
...
When we make a commit, it builds on all projects. Any idea??
This happens because each project has Webhook configured on GitHub and each time someone makes a commit, each project build is triggered by webhook. Then, regardless of what branch is configured for project (that is only default branch for manual/API builds), AppVeyor reads appveyor.yml from the branch where commit was done.
Solution is to use either alternative YAML file names or alternative YAML file location.
With alternative YAML file names you can have something like appveyor-dev.yml, appveyor-stage.yml files and set specific AppVeyor project to use specific file. With alternative YAML file location is it basically the same, but in other location than repo. I personally like alternative YAML file location more because of less duplication and potential merging issues.
In both cases when webhook in say branch dev come to stage project, it still will read appveyor-dev.yml and do the right filtering.

Pass Travis-CI tests with Bintray deployment code

I have a library that I want to use Travis-CI on.
It is written in Java and uses Gradle as a build system and deploy to Bintray.
When Travis-CI runs the tests, it fails because I do not store my username and password in plaintext in the git repo.
What went wrong:
A problem occurred evaluating root project 'project-name'.
Could not find property 'bintray_net_user' on com.jfrog.bintray.gradle.BintrayExtension_Decorated#18be0f81.
This is happening because I have not committed my gradle.properties.
How to I tell it not to run the deploy code, or otherwise fake it out?
I guess you're usually passing this property using -P commandLine option? The easiest fix for you might be to check if the property is available before you use it and initiate it with a sensible default if not:
if(!project.hasProperty('bintray_net_user')){
project.ext.bintray_net_user = 'default'
}
You can add user credentials stored to your .travis.yml secure environment variables.
Since you always have one of the two (local gradle.properties, or parsed .travis.yml), it will work correctly.

Create job in jenkins with calling svn and maven

For now I have a batch file with commands for update projects using svn and calling maven 'clean install'. How to create some job in Jenkins for similar actions?
Should I write it to ant file (sorry if it's stupid idea, I've just heard about it but I don't know what is it exactly and what can I do with this) or there is other way?
Thanks
Like arghtype suggested, you need to be using Jenkin's own Source Code Management by configuring SVN as SCM source and supplying credentials as part of Maven build job.
If you have to use your own local working copy, you are organizing it wrong, you will lose on all the benefits of having Jenkins manage SVN changes, and in the end, this organization will give you more unsolvable problems in the future. Think about the advice people are giving here and come with up a reason why you need to have a local workspace outside of Jenkins management on a Jenkins build machine. My only guess is: your Jenkins and Development machine are the same. That again is not how it should be organized. Jenkins is a CI-server, not a personal build "automator".
Regardless, if you still want to do what you say.
What you think you want
Create a new Freestyle job
Under Build Steps, click Add build step
Select Execute Windows batch command
Write your batch execute command in there. Your working directory will be Jenkins's $WORKSPACE, so change your path accordingly to where you want to run it.
But with the above configuration, you might have as well put the batch file under windows scheduler... You are not really using Jenkins with the above.
What you should do instead
Create a new maven2/3 build job
Under Source Code Management, select Subversion
Under Repository URL enter the remote SVN repo (i.e. http://your.svnsever.com/path/to/project)
Under Build, enter your Root POM location (this will be relative to the location of your SVN checkout, so if your POM is under http://your.svnserver.com/path/to/project/maven/pom.xml, then enter maven/pom.xml.
Under Goals and options, enter clean install
Click Save
The Source Code Management section will take care of setting up a local workspace and checkout the repository into that workspace. By default, every time a new build is triggered, it will run svn update on that workspace for you.
The Maven Build step will take care of running your Maven, however note that it is configured to use default ~/.m2/repository location. If your local maven repo needs to be different, change this under Jenkins Global Configuration
Create a new job.
In Source Management choose Subversion, specify your repo and credentials.
Add a new build step - maven build, specify your maven goals ('clean install').
Jenkins is a CI(contiounus integration) server. It can be used to generate scheduled builds of ant or maven based projects. It can also start building projects by some triggering event such as a commit to SCM (git, svn, mercurial,...)connected to it. You really have to read its documentation to get a better understanding. It has nice tutorials.

Downloading builds from TeamCity

Is there a way to download specific builds of a project in TeamCity?
You can use the build id, build number or one of the static build identifiers:
http://{TeamCity-Server}/repository/download/{BUILD_TYPE_ID}/{BUILD_NUMBER}/{ARTIFACT_PATH}
http://confluence.jetbrains.net/display/TCD65/Patterns+For+Accessing+Build+Artifacts
What you're actually looking to do is create artifacts in TeamCity. Artifacts are normally a build output which are then attached to the individual build runs so that you can download and review them at a later date. There's a walk through including the creation of build artifacts in You're deploying it wrong! TeamCity, Subversion & Web Deploy part 5: Web Deploy with TeamCity.
we attach the .msi file generated from the build as an artifact containing the build number (you can use %env.BUILD_NUMBER% to find the artifact path).
As mentioned above, one can download using REST API. It is also possible using FluentTc library with fluent api:
Download artifacts of the latest successful build:
IConnectedTc connectedTc = new RemoteTc().Connect(a => a.ToHost("tc")
.AsUser("MYUSERNAME", "MYPASSWORD"))
IBuild lastSuccessfulBuild = connectedTc.GetLastBuild(having =>
having.BuildConfiguration(with => with.Id("FluentTc"))
.Status(BuildStatus.Success));
IList<string> downloadedFiles = connectedTc.DownloadArtifacts(lastSuccessfulBuild.Id,
#"C:\DownloadedArtifacts");
Download specific file from artifacts of specific build by build Id:
string downloadedFile = connectedTc.DownloadArtifacts(
buildId,
#"C:\DownloadedArtifacts",
"binaries.zip");
To get latest successful build artifacts from Team City you can use the following link templates:
with guest authentication: http://<buildServer>/guestAuth/downloadArtifacts.html?buildTypeId=<buildTypeId>&buildId=lastSuccessful
with your credentials: http://<buildServer>/repository/downloadAll/<buildTypeId>/.lastSuccessful/artifacts.zip
with specific artifact: http://<buildServer>/httpAuth/repository/download/<buildTypeId>/.lastSuccessful/<some file.ext>

Resources