How to get files produced during a Travis-CI build? - travis-ci

I am using Travis-CI to test code in a repository. There are quite some files after the testing and I would like to have them at a persistent place. How can I do that under the context of Travis-CI?
As an artificial example, suppose my Travis-CI server runs a C program that stores a large number of integers in a specific file. The file can be found at the Travis-CI server after the build. But how can I get that file? In my use case, this file is large and it would not make sense to read it from the console of Travis-CI; in other words, I would not consider using "cat ..." in .travis.yml.

After some search, here is what I got:
The most convenient way seems to deploy the generated files to GitHub pages. The process is explained here: https://docs.travis-ci.com/user/deployment/pages/. In short:
first, create a GitHub page from the repository under test. This can be done through the Github web of the repository. The outcome includes an additional remote branch called gh-=pages generated.
then, in .travis.yml, use the deploy section to specify the condition to do the deployment.

Related

Is it possible to have multiple jobs or builds in workflow?

first let me tell you I am a quite beginner with Circleci, so some of my questions might not make too much sense but bear with me.
Recently I published a project of mine in Github PoC Akka FSM, I heard from several friends good things about Circleci and I am trying to use for my project.
Circleci web page created a config.yml for me and it is looking good but I have a complication, my Project is a Gradle Project but it has a dependency to Eclipse .p2 Repositories, which Gradle can't resolve out of the box. So I have a small Maven Project that collects my dependencies from .p2 repository and convert those to a big fat dependency jar.
Now when I locally build, I build first maven project which would place the the dependency in local maven repository, so the Gradle can locate the Artifact from Maven repository.
Now for the reason you might guess this is not working in Github with Circleci's default config.yml, so my question would it be possible to combine a maven build and gradle build in Circleci. Or a define in a prestep for an extra Build.
Otherwise I will try to convert Maven project to Gradle project (I am not sure Gradle would be able to read .p2 repositories).
The following is the Maven Project.
Thx for answers
I solved my Problem and I like to explain here how, in case another complete beginners lands here.
First, if you are complete new to CircleCI please start reading this before anything else, life would be much easier.
CircleCI Concepts
Secondly, this link
CirceCI Sequential Jobs
explains perfectly how Sequential Jobs should work, at the beginning the wordings 'Steps' being under 'Job' and 'Workflow' confused me a lot, I was not sure I have to implement my Maven Step in Job or Workflow, but it seems it must be Workflow.
Third, I was not quite sure how to transfer the Artefacts of Maven Build to Gradle Build, it seems Cache mechanism is responsible for it. When first I read it, a cache in Build System didn't not made too much sense but I think (I am completely speculating) caches in CirceCI is like Java Maps, you put in Job a value with key, next job can pick the value for key (value being here the Artefacts?). So I in my Maven Job, I am saving my Cache with Key "v1-dependencies-{{ checksum "fsm-akka-eclipse-dependencies/pom.xml" }}" and in the next Job, I load it with same key (and additionally v1-dependencies-{{ checksum "build.gradle" }} while I have a feeling if the checksum of 'build-gradle' is not changed CircleCI optimize something) Someone with more experience may be clear that here
Fourth, I was not sure how to say CircleCI to install Maven or Gradle but it seems CircleCI doing it in a magic way. In my previous point, I mentioned the caches to transfer the Artefacts', but for Maven Job, I am telling to save the cache at '.m2' directory which normally Gradle will look for Maven Artefact, may be this is doing the trick or the Cache I can't tell.
If you like the see how my final config.yml looks, you can find it on the link.

How to use a GitLab link for applying jenkins.yml file for the concept of Jenkins Configuration as Code

I have a local instance of Jenkins. I have previously tried storing the jenkins.yml in my system and giving its path on http://localhost:8080/configuration-as-code. This worked but I want to use a Gitlab repository to store the jenkins.yml file.
I have already tried giving the gitlab link of my jenkins.yml in the path or URL textbox. Some weird things happened, like
1. jenkins broke or huge error console
2. It reapplies the previous configuration(from system path)
jenkins:
systemMessage: "Hello, world"
Your problem as described: you want the job configuration to be saved in GIT and, when a build is triggered, the job should get the current stand of its configuration from there and then, run the build.
Maybe there is a kind of plug-in that does it for you, but I am not aware of any. Maybe anyone?
My suggestion is to define a pipeline job and use a declarative pipeline. It is a file, normally named Jenkinsfile that can be stored in GIT. In the Job, you define the GIT address and when you trigger a build, the file is got from GIT and executed.
There are several flaws in this: pipelines learning curve is not small, you are confronted with groovy (not XML!) and your current XML file is barelly useful.
Maybe someone shows up and tells us about new (for me) plugin that solves your problem using the configuration XML file. In the other hand, pipelines are such a beautyful feature that I encourage you to give it a try

Update Jenkins Plugins via Artifactory

I want to update Jenkins plugin via Artifactory.
Create a remote repo named Jenkins-update
Create a local repo named jenkins-update-center
Get the update-center.json from repo Jenkins-update to local and modify the URL from 'http://updates.jenkins-ci.org/' to my own URL 'https://artifacts.xxx.com/artifactory/Jenkins-update/' in update-center.json, then put update-center.json into local repo.
#!/bin/sh
curl -L -o /tmp/update-center.json http://localhost:8081/artifactory/Jenkins-update-cache/update-center.json
sed -i 's#http://updates.jenkins-ci.org/#https://artifacts.xxx.com/artifactory/Jenkins-update/#g' /tmp/update-center.json
curl -L -uuser:pass -T /tmp/update-center.json "http://localhost:8081/artifactory/jenkins-update-center/update-center.json"
Change the default update site from 'http://updates.jenkins-ci.org/' to 'https://artifacts.xxx.com/artifactory/jenkins-update-center/update-center.json' in Jenkins
There is an error 'SHA-512 digest mismatch: expected=49a22dc23f739a76623d10128b6803f79e0489de3ded0f1d01f3dfba4557136c7f318baaf4749a7713ec4b3f56633f2ac3afc4703e87d423ede029d68f84c74d in 'update site 'default''' when I click 'check now' button.
What should I do to make Jenkins update plugins from Artifactory?
Tkx
As soon as the content of update-center.json changed you need to re-generate "signature" section of this file.
For that you need to generate your key pair (see more details in How to create a local mirror of public Jenkins update site?)
Also you may use the following proposed approach :
there is probably a better way, by having a sandbox Jenkins on a system that has access to the internet. You update the server using the UI and then you can test that updated Jenkins thoroughly. When done, you just need to copy the war and hpi files over to your 'production' Jenkins. now you have even a nice process and QA in place.
Another way is to setup a transparent https proxy between your Jenkins and Artifactory server - in that case update-center.json will not change and signature verification should work fine.
With best regards,
Dmytro Gorbunov
As of 2023-01-10 there is a problem with making a mirror of the jenkins plugins on artifactory.
Artifactory documentation decribes only how to create a mirror: https://jfrog.com/knowledge-base/how-to-configure-artifactory-as-a-mirror-for-jenkins-plugins/
But this is not a complete solution. Because this leads to the situation when every plugin shall be manually updated. Having plugins with bunch of dependencies it is huge effort.
There is a need to generate a file: update-center.json
There is an internal jenkins tool to do this: https://github.com/jenkins-infra/update-center2, but documentation is poor and contains vague statements like:
With a few modifications it could easily be used to generate your corporate update center as well.
Without clear description, what shall be done.
I tried to follow steps and completely failed. Tool require some special environment variables, which are also not documented and so on.
So as of my experience mirroring jenkins plugins on artifactory is practically not possible. And honestly spoken, I would like to be wrong here.

Jenkins Conditional Build

I am completely new with Jenkins and have this question. So I created two projects on Jenkins. The first project will fetch from github if it notices any kind of change on my repo and will store a local copy on my machine.
The second project will start only if the first project is stable. If it is stable, the second project will first compile the all the java files (which I put in a compile.bat file), then it will run the testng.xml file which runs junit test and selenium test (run.bat file).
So what I want to do is if there is no compilation errors on compile.bat, then proceed on run.bat, but right now even though there are some errors on the java file and when the compile.bat runs, it catches those errors, Jenkins still proceeds to the run.bat file and at the end passes the build. I want the build to fail when there is any kind of errors.
Here is the link to my repo for the batch file and other files if that helps:
https://github.com/na2193/Demo
I had figured it out. You need to use conditional step(single) and there you can define what you want to do

Post Deployment JVM log validation for JBOSS and WAS Application

We use Jenkins and Urban Code Deploy to do our builds and deployments respectively. Post the deployment we manually go ahead and validate the JVM logs. Most of the Applications we deploy are JBOSS and WAS8.5. I wanted some suggestion on automating this post deployment validation task. Is there any tool, plugin that can be integrated with Urban Code Deploy to perform this log parsing against certain keywords.
I have "Log parser" plugin which is an open source plugin in Jenkins. Are there any better ideas?
In UrbanCode Deploy you can use the step called "Monitor File Contents" to check if a regular expression is contained in a file.
Another way would be to output the log file content in a shell step, like cat logfile, and then use a post-processing script to check if an expression is in the file. In this case, you can use JavaScript syntax. See

Resources