Jenkins failure during trigger - jenkins

When executing a job I made I got an error before the execute shell had been executed (so this error must come from Jenkins or Git).
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/Deploy example.com master branch
Checkout:Deploy example.com master branch / /var/lib/jenkins/workspace/Deploy example.com master branch - hudson.remoting.LocalChannel#51a745fc
Using strategy: Default
Last Built Revision: Revision 133257b4b34f8c0a90bf5ce11c634ebc9587d20d (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://joachimroeleveld:fod4xvo0#bitbucket.org/joachimroeleveld/exofes_profiler.git
Commencing build of Revision 133257b4b34f8c0a90bf5ce11c634ebc9587d20d (origin/master)
Checking out Revision 133257b4b34f8c0a90bf5ce11c634ebc9587d20d (origin/master)
Triggering default
default completed with result FAILURE
Finished: FAILURE
What does ' default' mean in this case? Clicking on it results in a page with the links 'Workspace' and 'Recent changes'. Does this error come from a misconfiguration in Git (I use BitBucket for my remote repo's) or Jenkins?

You might be using multi-configuration job.
If this is the case try to configure "a free-style software project" first. The log will look like the following:
Started by an SCM change
Checkout:...
Using strategy: Default
Last Built Revision: Revision ...
Fetching changes from 1 remote Git repository
Fetching upstream changes from ...
Commencing build of Revision ...
Checking out Revision ...
[job-name] $ /bin/sh -xe /tmp/hudson7227596484536996852.sh

Related

Jenkins #Library resolution failing due to git.exe not existing, but where?

I have this command at the top of my pipeline file, and my build failed immediately in Jenkins while trying to resolve it:
#Library('MyLibrary') _
pipeline{
...
I also have this library setup in my global jenkins config. Triple checked it.
The Jenkins log is below... the internet says this happens when git.exe is misconfigured or not found. We have 100% verified git is installed on all the slaves. However, I suspect that this failing git clone is running somewhere else since the pipeline has not officially started yet (we don't see RUNNING ON: blah in the log).
So... Does it run this on the master? We have master set to 0 executors, and git is not installed there.
Is this problem solved as easily as installing git on the master? Or is there some other magical place where these #Library includes get cloned?
Here is the Jenkins log output, with names changed to protect the innocent:
Started by user Me
15:28:23 Connecting to my github url
Obtained Jenkinsfile from blah
Running in Durability level: MAX_SURVIVABILITY
Loading library MyLibrary#master
Examining <my github repo>
Attempting to resolve master as a branch
Resolved master as branch master at revision blah
No credentials specified
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository <my repo url>.git
> git init /home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:813)
...
Caused by: java.io.IOException: Cannot run program "git" (in directory
"/home/afolder/jenkins/workspace/<git repo name>#libs/MyLibrary"):
error=2, No such file or directory
Yes, by default it will run on the Jenkins master.
Please follow the link for more info.
You can read library file and give the file to writeFile pipeline step
writeFile(file:"foo.groovy", text: libraryResource("bar.groovy"))
"groovy foo.groovy"

trigger open source jenkins job for a github merge

This is our tool set:
jenkins: Open source Jenkins running on AWS server - 2.107.2
Github: 2.13.3 version
Requirement:
We need to create a GitHub hook in such a way that, if anyone merges the branch (create pull request and merge it), then it should trigger the Jenkins job.We do not use multibranch pipeline, we use just pipeline jobs i.e we use jenkisnfile to run our jobs.
so, i have enabled the "PullRequestEvent" in github webhooks. Then i have enabled scm polling in Jenkins job for that particular job.But, the issue is the job is getting triggered for a commit to the xyz branch and also if we merge the pull request. But, the expected behavior is, the job should be triggered only for the merge.
polling log :
This page captures the polling log that triggered this build.
Started on Jul 17, 2018 2:04:00 PM
Using strategy: Default
[poll] Last Built Revision: Revision xyzz (origin/development)
> /app/digital/tools/git/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials Githubread id generated on 20th Jan 2017
> /app/digital/tools/git/bin/git ls-remote -h https://github.xyz.net /abc/Test-SourceCode-Jenkins # timeout=10
Found 3 remote heads on https://github.xyz.net/abc/Test-SourceCode-Jenkins
[poll] Latest remote head revision on refs/heads/development is: xyzz
Done. Took 1.8 sec
Changes found
jenkins configuration:

Error when deploying Lektor site to Github Pages using Travis CI

I've got a Lektor site that I'm trying to deploy automatically in response to pull requests and commits, using the Travis CI trigger approach from the Lektor docs.
The Lektor configuration works fine from the command line.
The Travis build starts, and appears to build the site without problem - but when it gets to deployment, the log says the following:
Installing deploy dependencies
!!! Script support is experimental !!!
Preparing deploy
Cleaning up git repository with `git stash --all`. If you need build artifacts for deployment, set `deploy.skip_cleanup: true`. See https://docs.travis-ci.com/user/deployment/#Uploading-Files.
No local changes to save
Deploying application
Deploying to ghpages-https
Build cache: /home/travis/.cache/lektor/builds/d3a411e13041731555222b901cff4248
Target: ghpages+https://pybee/pybee.github.io?cname=pybee.org
Initialized empty Git repository in /home/travis/build/pybee/pybee.github.io/temp/.deploytemp9xhRDc/scratch/.git/
Fetching origin
fatal: repository 'https://github.com/pybee/pybee.github.io/' not found
error: Could not fetch origin
fatal: repository 'https://github.com/pybee/pybee.github.io/' not found
Done!
For a full log, see here.
I've checked the credentials in the Travis CI configuration for the repository; I'm as certain as I can be that they're correct. I've tried using the same configuration (exporting LEKTOR_DEPLOY_USERNAME and LEKTOR_DEPLOY_PASSWORD locally), and it works fine.
hammer:pybee.org rkm$ lektor deploy ghpages-https
Deploying to ghpages-https
Build cache: /Users/rkm/Library/Caches/Lektor/builds/a269cf944d4302f15f78a1dfb1602486
Target: ghpages+https://pybee/pybee.github.io?cname=pybee.org
Initialized empty Git repository in /Users/rkm/projects/beeware/pybee.org/temp/.deploytempOh4p98/scratch/.git/
Fetching origin
From https://github.com/pybee/pybee.github.io
* [new branch] master -> origin/master
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Everything up-to-date
Done!
Any suggestions on the cause of this error?
It turns out this is a bug in Lektor.
If you use the following in your <project>.lektorproject:
[servers.ghpages-https]
target = ghpages+https://pybee/pybee.github.io?cname=pybee.org
and the following in your .travis.yml:
language: python
python: 2.7
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/lektor/builds
install: "pip install git+https://github.com/singingwolfboy/lektor.git#fix-ghpages-https-deploy#egg=lektor"
script: "lektor build"
deploy:
provider: script
script: "lektor deploy ghpages-https"
on:
branch: lektor
(i.e., use the PR branch for deployment), builds will deploy as expected.

Jenkins gerrit trigger not fetching my change while building

I have configured jenkins with gerrit trigger plugin to validate every commit we push to gerrit.
I am expecting this trigger to include my latest change with original repo and make a build.
But, it is cloning only repo project and compiling without my change.
Below is my configuration settings for gerrit trigger in jenkins.
Refspec: $GERRIT_REFSPEC
Branches to build: $GERRIT_BRANCH
Build trigger: Gerrit event
Trigger on: patch set created
Gerrit project: added project and branch
Below is the build output message
Triggered by Gerrit: http://ci-test1/22
Building on master in workspace /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Build_Adserver_4.7/workspace - hudson.remoting.LocalChannel#733aee56
Using strategy: Default
Last Built Revision: Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Fetching changes from 1 remote Git repository
Fetching upstream changes from abc
Commencing build of Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
Checking out Revision 701a75ef38aa191ac1b806c48e6b3451671888f6 (ads/4.7)
[workspace] $ /bin/sh -xe /tmp/hudson1375188638196718521.sh
+ echo 'Started Build'
Started Build
+ echo ..................
..................
+ echo 'Build Finished'
Build Finished
Finished: SUCCESS
Here 701a75ef38aa191ac1b806c48e6b3451671888f6 is HEAD of repo branch and 8cbda558adcad4fb7eb714e0b3fb98a6fbf5811c is the SHA-id of my latest change trigged the build.
I verified from jenkins workspace also, it doesn't include my change.
sorry if I am missing any information to mention. Please let me know
please help me if I am missing anything here.
Using Jenkins 1.532.2 Git Client Plugin 1.6.2 Git Plugin 2.0.1 Git Trigger 2.11.0
Here are the steps for configuring the Gerrit Trigger (from memory, hopefully all works fine):
Install the plugin(s) "Gerrit Trigger", "Git Plugin" and "Git Client Plugin"
In the main jenkins config (HOME->Manage Jenkins), click on Gerrit Trigger.
Create the server and configure it. Use "Test Connection" to be sure it works.
At the end, under "Control" press "start" (No idea what that does or if it's actually needed, but I did that).
Go to your project's config (MYPROJECT->Configure)
Check "Gerrit event" under "Build Triggers"
In the newly added menu, select your server, your triggers, etc.
For Gerrit Project I used "Plain" with "MYPROJECT" as pattern
For Branch, I used "Path" and "**" as pattern (builds all branches)
Under "Source Code Management" (up from triggers in my UI), click on "Git"
Set the Repository URL, here $USER matches for me, but otherwise write the correct user $GERRIT_SCHEME://$USER#$GERRIT_HOST:$GERRIT_PORT/$GERRIT_PROJECT
Specify a branch: $GERRIT_BRANCH
Under "Repositories" on the right, click Advanced, for "Refspec" enter $GERRIT_REFSPEC
Click Add right below, and select "Strategy for choosing what to build"
Select "Gerrit Trigger"
Not very intuitive but it should work. I suggest making sure the correct SHA1 Ids are being built.
If run into Error stderr: fatal: Couldn't find remote ref $GERRIT_REFSPEC
You have to change the Choosing Strategy to Gerrit Trigger
Go to the configuration page of your job and then click on the 2nd Advanced button under the git section. Almost at the bottom there is a Choosing Strategy that you will need to change to Gerrit Trigger
This will cause Git to fetch the correct version for your build
Fixing small issues in Lewis answer, change the values to the following to ensure the latest SHA1 is built.
branch: $GERRIT_REFSPEC
REFSPEC: $GERRIT_REFSPEC:$GERRIT_REFSPEC
I am using Jenkins 2.15 and faced the Issue and got resolved with following settings.
In Git Advances add Refspec : $GERRIT_REFSPEC
Branches to build : $GERRIT_BRANCH.
In Addititional behaviors section select Strategy for choosing what to build and select gerrit Trigger.

Jenkins stopped work on checking out revision

I have problem with Jenkins bilds.
Sometimes my build hangs on operations "Checking out Revision". The problem is not constant. I can get this issue in 4-5 times of 10 bilds.
I am waiting 10-20 minutes and the abort this hangs bild.
Console log:
Started by upstream project "master" build number 737
originally caused by:
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/master/workspace/CI_BUILD/integration
Checkout:integration / /var/lib/jenkins/jobs/master/workspace/CI_BUILD/integration - hudson.remoting.LocalChannel#29b99c
Using strategy: Default
Last Built Revision: Revision e0963076406dd8bd6fcbd2d31ff37ad4ea60669a (origin/master)
Fetching changes from 1 remote Git repository
Fetching upstream changes from git#github.com:shaliko/shaliko.git
Commencing build of Revision e0963076406dd8bd6fcbd2d31ff37ad4ea60669a (origin/master)
Checking out Revisione 0963076406dd8bd6fcbd2d31ff37ad4ea60669a (origin/master)
In Jenkins config:
6 executors
Quiet period 10
SCM checkout retry count 10
I update Jenkins to version 1.500 and update "Jenkins GIT plugin" to version 1.1.26 - no effect.
What I should check or update?
Fixed issue by updating JDK to version 7u11.
Thanks for the advice!

Resources