Multi-configuration job - where is the output? - jenkins

I'm a newbie to Jenkins, so perhaps it is a stupid question, but...
I'm trying to write a job that will compile my code on several UNIX nodes. I created a multi-configuration project, and add one slave to it.
The job itself is a shell that only does 'ls' and 'pwd'
The output is:
Started by user anonymous
Building on master in workspace C:\Program Files (x86)\Jenkins\workspace\Unix-third-party
Triggering Linux64
Linux64 completed with result SUCCESS
Finished: SUCCESS
But I can't see the output of the commends anywhere.
When I changed the matrix to use nodes instead of labels, I managed, to see the output, but I'm still not sure what I did.
A free-style project for the same node works with no problems.
Where do I find the output?

On your job page, you'll see a link called "default" if you have only one node/slave, or the node's name if you have more than one.
Click on that link, then click on a build and console output.
The way it works is:
-----------------config 1 -> build #X -> console output
/
Main Job build #X console output ---->
\-----------------config 2 -> build #X -> console output
What you are looking at is the console output for the main job, but this only contains trigger information. The actual output is contained in the config 1 and config 2 console outputs.
Comment if you need further clarification, and I'd be glad to help.
Btw, welcome to the world of Jenkins :-)
==========================================================================
EDIT:
The following URL should take you to yourc console output for a build where you've chosen "Label":
Substitute everything in <>.
http://<myserver>/job/<jobname>/label=<label>/<buildnumber>/console

Not sure if this will help you, however at work, to view our slave consoles, the following URL will work:
https://ci.(company).com/job/QA/job/[projectname]/13/script=loadtest1/console
I'd assume your system would be similar.
Alternatively, if i go to the main ci.(company).com/job/QA/job/[projectname]/
i can see the recent job on the left corner.
When selected that specific job, at the base of the screen is our configurations, which you select, then can view the console output of that specific job.
Viewing the main jenkins job will not output console logs from slaves.

I ran into this today, not sure what caused it, but I was able to get my build configs to show console logs and artifacts once more by deleting "builds" and "configurations" folders under "C:\Program Files (x86)\Jenkins\jobs\ProjectName".
Obviously, this also gets rid of your build history, but I just need the configs running again.

Related

I have Job A and B in Jenkins. How can I always execute a file in the most recent build of A in the build steps in job B

I have these Jenkins jobs A and B. Job A Builds a bunch of Files for my project. In Job B i wanna execute a command to run a file in the most recent build of job A.
My execution even works fine, but only because I have hard coded the build number and I am picking that from the files stored by Jenkins in my C:JenkinsData Directory, I would wanna have that called from the Workspace instead
See image for clarification.
Jenkins build steps illustration
For e.g my last build right now is 70 I want to know how I can be always executing those same files but in the most recent Build
Or if its even way better Can I execute those same file from Job A since the built files are in the Workspace.
You could get the last build index using this API and "number" property:
/lastBuild/api/json
ie:
http://localhost:8080/job/yourJobName/lastBuild/api/json
This could help:
Jenkins - Get last completed build status

Jenkins configurations gets reverted by SYSTEM user anomaly

I am running Jenkins version 2.85 on Kubernetes as pod(Affinity set to one workernode). I am creating Jobs using Salt Jenkins module by passing XML to this module.
I am using Jenkins Global Library for preforming job execution.
My Job config looks like this
I am calling GobalLibrary with my parameters like repoURL, componet etc..,
Things goes well for weeks and now I landed to a weird situation where my job configurations(config.xml) gets updated/revert automatically.
Intermittently my "Build with parameter" options disappears and I can see only "Build now" in Jenkins GUI. Initially I thought someone is doing this, so to track the config changes I installed Job config history plugin in Jenkins and what I find is strange. Someone with "SYSTEM" username is making/reverting changes.
This is how it looks
and what I find is SYSTEM user revert only JOB config changes, not the PIPELINE.
I am not sure what's going wrong behind the scenes and how to stop or fix this. This is my Production instance so I am more worried.
I can see a SYSTEM user in my Jenkins
but I can not delete that user
Few relevant Question I find for this but with no answers
Configuration of Jobs getting updated by System user on Jenkins
Jenkins SYSTEM user removes custom workspace configuration
I am not sure if this Jenkins Bug or some plugin is playing with my soul.
Need help! :(
Okay I find the answer to this problem.
I have used properties in my Jekins Global Library something like this
// Disable concurrent builds
//properties([disableConcurrentBuilds()])
which overrides my external job configuration(done via salt).
Hint I get from this blog:
https://st-g.de/2016/12/parametrized-jenkins-pipelines
I also had this problem. For me it was solved when I changed the Build triggers -> Build Periodically settings from 'H 23 * * *' to '00 23 * * *'. (As I want my build to execute every night at 23:00.) Where H lets Jenkins decide when to run the job somewhere between 23:00 and 23:59 to spread load evenly. It seems Jenkins sometimes decided that it would be best to run my job on a different server and changed the parameters automatically.
In my case the issue was that the Jenkinsfile was removing the parameters I added to the pipeline from Jenkins console. Adding the same parameters in the JenkinSfile (stage -> script -> properties -> parameters) solved the issue.
In a nutshell, make sure that your Pipeline script is using the same configuration that your pipeline uses.
Jenkins documentation on parameters: https://www.jenkins.io/doc/book/pipeline/syntax/#parameters

Console output while running Jenkins

I am using Jenkins. I can see console output for jobs that have finished. But, how do I view the console out for Jenkins jobs that are in progress?
I think the question is how to see the output of the individual job, not the Jenkins system log. You can view console output of a job in progress by going to the page for that job in Jenkins and clicking on the colored ball for that job. The running build will have a flashing ball, while the completed jobs will not be flashing. In addition, you can click on the progress bar for a running job to see the console output.
The answer to this question very much depends on how you are running Jenkins. For example first example in the starting Jenkins guide demonstrates the following:
$ nohup java -jar jenkins.war > $LOGFILE 2>&1
Here you explicitly send the console output to a file. The problem is that there are lots of other ways to run Jenkins, so you are probabily better off configuring logging:
https://wiki.jenkins-ci.org/display/JENKINS/Logging
This will work if Jenkins is deployed inside a container like tomcat.
Update
The system log is available from the "Manage Jenkins" -> "System Logs" screen. It contains most of what will appear on the console:
http://<hosthname>:<portnumber>/log/all
You can view the console output for Jenkins jobs that are in progress by the following two steps below:
On Build History click on the progress bar.
Click to see
On the next window click on the Console Output to see the console output.
Click to see

Jenkins logs for a perl build file

Today I started working with jenkins and I successfully added my projects to jenkins and it says all works fine . one of the build takes more than 5 hours but didn't finish either so aborted it(while manual build takes less than 1 hour).. and while i tried to check with the log the log was not detailed. so i tried to get the logs of the perl script by running it as a shell command
usr/local/bin/perl perlscript.pl>logfile.txt
there was no log written and there was no evidence of the build triggered either cases.i'm not aware of what the problem is as both the perlscript(works fine while manually triggered) and jenkins are working properly except this project. I would like to have your help.thanks in advance
A few things you should understand about Jenkins:
Jenkins shows STDOUT as the log of the Job,
so if you redirect it to a file - nothing will be shown in the log.
Depending on how you have set it up, Jenkins may run as its own user,
which may change the behavior of your scripts.
You can confirm this by echo-ing the username at the beginning of your Execute Shell block,
for example:
echo $USER
Each Jenkins-Job is run from its own workspace -
you can confirm that location by simply printing the current working directory
at the beginning of your Execute Shell block, for example:
echo my current directory is
pwd

Promoting build does not run other projects

I am looking for a way to build continous delivery with cloudbees,so each time a commit is made my code is compiled,unit tested and deployed to staging (running on run#cloud).
For simplity let's call it "staging-build". Then after some manual testing on staging env i would like to have an option to promote a particular (not the last) "staging-build" so the artifact the promoted build produced should be deployed to production env via "prod-build" job.
The basic idea was to configure "promote build" for "staging-build" job with building "prod-build" as promote action. Nevertheless clicking on promote-build does not trigger starting "prod-build". I also tried from the other side: removed building "prod-build" as promote action and enabling "Build when another project is promoted" within "prod-build" configuration. Still no success. After googling for a while i found
http://blog.cloudbees.com/2012/10/continuous-integration-for-mobile-apps.html. Nevertheless blog entry along with jenkins configuration screenshots do not reflect configurations on https://partnerdemo.ci.cloudbees.com
I finally found the root of problem: jobs to be run on promotion must be prefixed with folder name (obviously in case they are in folder). In other case their run is silently skipped - even promotion log has no "scheduling build for ..." entry. IMHO Jenkins web console should show some kind of warning in that case, just like it does when invalid job name is typed-in.
configuring a promotion to trigger your prod-build job is the way to go. There may be some configuration issue that isn't visible in your question. Please give me your account ID so I can double check your configuration

Resources