Jenkins master throwing java.io.IOException when running pipeline in swarm client - jenkins

Im trying to run a pipeline job in an agent which is using swarm client. The job runs fine but im getting a lot of error messages in the log like below:
Cannot contact tst_db2: java.io.IOException: Remote call on Channel to /XX.XX.XX.XXX failed
(actual IP address replaced with XX)
In my observation the master is throwing this errors while waiting for the script that is running in the client. Again, the pipeline job run perfectly except that im getting this error on the pipeline logs.
Below is my pipeline script:
pipeline {
agent none
stages {
stage('Recreate DB') {
agent { label 'tst_db2'}
steps {
checkout([$class: 'SubversionSCM',
additionalCredentials: [],
excludedCommitMessages: '',
excludedRegions: '',
excludedRevprop: '',
excludedUsers: '',
filterChangelog: false,
ignoreDirPropChanges: false,
includedRegions: '',
locations: [[credentialsId: 'a84f7197-929a-437e-9aac-ca09fcd4c63a',
depthOption: 'infinity',
ignoreExternalsOption: true,
local: '',
remote: 'svn://XXXXX/XXX/tags/CR/Rebuild_VCRDWD01']],
workspaceUpdater: [$class: 'CheckoutUpdater']])
sh 'Rebuild_VCRDWD01/recreate_db.sh'
}
}
}
}
Is there anyway we can get rid of this errors?
Environment:
Jenkins Version : 2.32.2
Running on Windows Server 2012 R2
Swarm Client 3.3 on AIX 7.1 and JDK 8
Also raised a Jenkins issue: https://issues.jenkins-ci.org/browse/JENKINS-42428

A user in the ticket mentioned previously reported that they were able to get rid of the error by downgrading the "Pipeline: Nodes and Processes" plugin in Jenkins to 2.8 - available from here. I was able to get rid of the problem as well by doing that. Unfortunately there are a number of other plugins I have installed that are dependent on version 2.10. I'm not keen on backleveling all of those, so guess I'm going to have to live with this as an annoyance until there's an official fix from the plugin maintainer. Hopefully that will be soon.

Related

How do I dynamically load a Jenkins pipeline library from Perforce? [duplicate]

In continuation to jenkins-pipeline-syntax-for-p4sync - I am not able to get the "Poll SCM" option work for my pipeline job.
Here is my configuration:
"Poll SCM" is checked and set to poll every 10 minutes
Pipeline script contains the following:
node ('some-node') // not actual value
{
stage ('checkout')
{
checkout([
$class: 'PerforceScm',
credential: '11111111-1111-1111-1111-11111111111', // not actual value
populate: [
$class: 'AutoCleanImpl',
delete: true,
modtime: false,
parallel: [
enable: false,
minbytes: '1024',
minfiles: '1',
path: '/usr/local/bin/p4',
threads: '4'
],
pin: '',
quiet: true,
replace: true
],
workspace: [
$class: 'ManualWorkspaceImpl',
charset: 'none',
name: 'jenkins-${NODE_NAME}-${JOB_NAME}',
pinHost: false,
spec: [
allwrite: false,
clobber: false,
compress: false,
line: 'LOCAL',
locked: false,
modtime: false,
rmdir: false,
streamName: '',
view: '//Depot/subfolder... //jenkins-${NODE_NAME}-${JOB_NAME}/...' // not actual value
]
]
]
)
}
stage ('now do something')
{
sh 'ls -la'
}
}
Ran the job manually once
Still, polling does not work and job does not have a "Perforce Software Polling Log" link like a non-pipelined job has when configuring the perforce source and Poll SCM in the GUI.
It's like the PerforceSCM is missing a poll: true setting - or i'm doing something wrong.
Currently I have a workaround in which I poll perforce in a non-pipelined job which triggers a pipelined job, but then I have to pass the changelists manually and I would rather the pipeline job to do everything.
edit: versions
jenkins - 2.7.4
P4 plugin - 1.4.8
Pipeline plugin - 2.4
Pipeline SCM Step plugin - 2.2
If you go to the Groovy snippet generator and check the "include in polling" checkbox, you'll see that the generated code includes a line item for it:
checkout([
poll: true,
As an aside, you may run into problems at the moment using ${NODE_NAME} in your workspace name. The polling runs on the master, so it might not properly find the change number of your previous build. If that's the case, I know a fix for it should be coming shortly.
After updating all the plugins to latest (as of this post date) and restarting the jenkins server - the polling appears to be working with the exact same configuration (job now has the poll log link).
I'm not sure what exactly resolved the issue - but I consider it resolved.

Trigger pipeline after a push on bitbucket server

I'm creating this new Job based on pipeline on jenkins. I want my jenkinsfile to be on bitbucket reposiotry : Let's say my config file is on bitbucket.org/config.git
The job mission is to clean install a project bitbucket.org/myProject.git
How can I configure the pipeline so it will trigger if any push is made in bitbucket.org/myProject.git and following the steps defined in bitbucket.org/config.git?
I do not want to create multi-branch pipeline and I do not want my jenkins file to be on the same repository than my project to compile.
My current config is:
pipeline {
agent any
parameters {
string(defaultValue: '', description: 'URL', name: 'GIT_URL')
string(defaultValue: '', description: 'Credential', name: 'CREDENTIAL_ID')
}
stages {
stage ('Initialize') {
steps {
git branch: 'develop', credentialsId: "${params.CREDENTIAL_ID}", url: "${params.GIT_URL}"
}
}
stage ('Build') {
steps {
sh 'mvn clean install '
echo 'build'
}
}
}
You can use shared Libraries in Jenkins. you would still need a Jenkinsfile in your code, but that would not contain any logic. It would simply refer the shared library and pass any params like git repo path.
For more information on shared libraries please refer this link https://jenkins.io/doc/book/pipeline/shared-libraries/.
For triggering the build, you can define a trigger in your pipeline. Example :
triggers {
pollSCM('H/5 * * * *')
}
or use webhooks if you don't want to poll.
Actually, i managed to make it work.
In my jenkins pipeline, i activated "Build when a change is pushed to BitBucket".
node {
checkout([$class: 'GitSCM',
branches: [[name: 'feature/test-b']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption', disableSubmodules: false,
parentCredentials: false, recursiveSubmodules: true, reference: '',
trackingSubmodules: false]], submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'admin',
url: 'http://localhost:7990/scm/bout/boutique-a.git']]])
}
When a change is made in boutique-a in the branch 'feature/test-b' my job is triggered which is cool.
Now i have this other issue, how can i trigger when change are made in feature/*
It looks like i cannot access to env.BRANCH_NAME when im not in a multibranch pipeline

How to do a sparse checkout and update from SVN on Jenkins?

We have a large SVN repository and I would like to do a sparse checkout on Jenkins. I do understand the concept of sparse checkouts and having it locally I can get things to work as I would like to have it. Doing things on Jenkins however and running it repeatedly I can't get to work.
I have a repo structure as follows
trunk\file.txt
trunk\FolderA
trunk\FolderB
trunk\FolderC
trunk\FolderD
I would like to checkout and update
trunk\file.txt
trunk\FolderA
trunk\FolderB
but NOT
trunk\FolderC
trunk\FolderD
My pipeline code is as follows
checkout([$class: 'SubversionSCM',
additionalCredentials: [[credentialsId: strCredentialsId, realm: strRealm]],
excludedCommitMessages: '',
excludedRegions: '',
excludedRevprop: '',
excludedUsers: '', filterChangelog: false,
ignoreDirPropChanges: false,
includedRegions: '',
locations: [
[
remote: "${strRepoPath}/trunk",
local: "${softwarePath}",
depthOption: 'unknown',
credentialsId: strCredentialsId,
cancelProcessOnExternalsFail: true,
ignoreExternalsOption: false
],
[
remote: "${strRepoPath}/trunk/FolderA",
local: "${softwarePath}/FolderA",
depthOption: 'infinity',
credentialsId: strCredentialsId,
cancelProcessOnExternalsFail: true,
ignoreExternalsOption: false
],
[
remote: "${strRepoPath}/trunk/FolderB",
local: "${softwarePath}/FolderB",
depthOption: 'infinity',
credentialsId: strCredentialsId,
cancelProcessOnExternalsFail: true,
ignoreExternalsOption: false
]
],
quietOperation: false,
workspaceUpdater: [$class: 'UpdateWithCleanUpdater']])
Whenever I run this code the first time, everything looks as expected. However, when Jenkins runs it the following times, the UpdateWithCleanUpdater causes that FolderA and FolderB get first deleted and then checked out again. The result is still correct, however, it takes much longer that I would like it to take and longer than necessary.
I would like to keep the UpdateWithCleanUpdater because I want Jenkins to clean up files generated in the previous run.
Is there any solution to this using the Jenkins SVN plugin? How would I do this "manually", i.e. do a checkout the first time, clean up and only update the following times, and still do automatic Jenkins runs based on change detection on the SVN repo?
Thanks in advance!
Now that is a very narrow issue.
I'd say, either you replace the UpdateWithCleanUpdater with a manual script (by calling your local svn client; some examples here); or you could fork or contribute to the Jenkins SVN plugin.
On the trunk you have:
depthOption: 'unknown',
Shouldn't the value be 'empty'?
Yet, while what that might avoid the "FolderA and FolderB get first deleted and then checked out again", so I doubt that you would really get the "sparse checkout" in this way. It will be rather a "normal checkout into another SVN workspace".
As a workaround you can consider using svn:externals: Create a folder trunk/JenkinsWorkspace/trunk, and set svn:externals property with a content like:
^/trunk/FolderA FolderA
^/trunk/FolderB FolderB
^/trunk/file.txt file.txt
Then, in Jenkins you would just have a single checkout from ${strRepoPath}/JenkinsWorkspace.

Jenkins Sshagent plugin in slave not working as expected

I am trying to use the sshagent and credentials plugin to execute couple of git commands on a remote repo in a jenkins pipeline script .
I am trying to do this checkout some files from a large repo . This runs on a docker slave .
sshagent(['a5f11347-dff6-4586-ae77-34adeffb0063']) {
script {
sh 'git archive --remote=ssh://git#git.comp.com/something.git HEAD Jenkinsfile | tar -x'
sh 'git archive --remote=ssh://git#git.comp.com/something.git HEAD:pipeline/ | tar -x;'
}
}
But it fails with a hostkey verification failed error. Any insight on why this is failing .
If i do a
checkout([$class: 'GitSCM', branches: [[name: "${BRANCH_NAME}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true],
[$class: 'CloneOption', noTags: true, reference: '', shallow: true],
[$class: 'SparseCheckoutPaths', sparseCheckoutPaths: [[path: 'Jenkinsfile'], [path: 'pipeline/*']]]],
submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'a5f11347-dff6-4586-ae77-34adeffb0063',
url: 'ssh://git#git.comp.com/something.git']]])
it works fine ,but the large repo is fetched ,which i want to avoid
Regarding the host key verification problem, you need to add the host key for git.comp.com to your SSH known_hosts file. Try integrating the following command in your Jenkins script before the sshagent block:
ssh-keyscan git.comp.com >> ~/.ssh/known_hosts
This worked for me.
See Jenkins ssh-agent starts and then stops immediately in pipeline build for more info.

jenkins pipeline warnings graph

I started to migrate some jobs in jenkins to pipeline execution.
Is there any chance to see the warnings graph in multi branch pipeline jobs? Within my older projects I can configure the graphs with "Configure the trend graph" option. These option will crash in the pipeline syntax tool.
Is there any option to make the graph visible?
I have in my Jenkinsfile:
stage ('Warnings gcc') {
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'GNU Make + GNU C Compiler (gcc)', pattern: 'error_and_warnings.txt']], unHealthy: ''])
}
stage ('Warnings clang') {
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'Clang (LLVM based)', pattern: 'error_and_warnings_clang.txt']], unHealthy: ''])
}
The reports will be generated but no graph is displayed.
UPDATE: Now it still did not work but it is also impossible to use the snipped generator for the warnings plugin.
Entering a file name in the snipped generator for the warning plugin results in a java null pointer exception:
javax.servlet.ServletException: java.lang.NullPointerException
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:796)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362)
some more lines follows ...
Mentioned in the revision log for the warnings plugin V 4.56:
Fixed deactivation of trend graphs (using the analysis collector plug-in)
But I use 4.57 and it still did not display any graph!
I posted the problem also to jenkins user list (no feedback for weeks) and also added bug report and bug report
Can anyone reproduce the problem or is the multi-branch pipeline simply still broken at all? Seems to be that there are not so much users for this plugin...
These issues have been resolved with the latest versions of both Jenkins, the pipelines plugin[s], and the plugins you have mentioned above.
Additionally, the bugs you specifically reported have been resolved:
[FIXED JENKINS-39553] Make GitHub plugin BuildableItem aware (#153)
[FIXED JENKINS-39532] Do not access the workspace for pipelines
Update your Jenkins instance and all of your plugins (some of them have interdependencies on others) and after the suggested restart you should be able to display the graph successfully.

Resources