How to suppress Jenkins groovy Logs - jenkins

I am trying to execute Jenkins checkout command to checkout source files from subversion repository. When I execute command on a new workspace, it will display complete logs of checkedout files. Is there a option to disable logs and enable only when it is required?

Seems like a quiet checkout improvement is in the works, but not yet released.
https://issues.jenkins-ci.org/browse/JENKINS-14541

Related

Jenkins: Suppress builds after commit by a system user possible?

have a localiziation build in Jenkins (sources are in SVN) that has a commit by the build user as last build step - due to shortcomings of the used localization tool (Passolo).
Is there a way to suppress the triggering of a new build when the commit was done by this special build user or to kill those jobs immediately?
TIA, Franz-Josef
The solution ist to use the "revprop" attribute in your build script, like so:
svn commit -m "Commit via Jenkins" --with-revprop NoAutoBuild
Inside Jenkins configuration, you can exclude revisions using this property from starting a new build, you find the option in the SVN section of the Jenkins configuration page (screenshot, alas, in German):
sreenshot showing the "exlude revprop" section of the SVN plug-in inside Jenkins configuration
Hope this helps you (and me, if I forget until next time :-)

How to copy only changed files with Publish over SSH

I'm setting up Jenkins to build and then send changed files to a remote server using SSH. However, using the Publish over SSH plugin, I can only find an option to specify files to send over. I only want to send over files that have changed on GitHub. Is there a way to achieve this?
What you want to do might be outside of the scope of the Publish Over SSH plugin, but it is doable as a shell script.
You can run a command like this to get the files changed between the current commit and the last commit: git diff --name-only $GIT_PREVIOUS_COMMIT $GIT_COMMIT
Then using the results of that you can run a shell scp command.
You can do this in a pipeline or in a execute script post-build action.

How to run Jenkins pipeline automatically when "git push" happens for specific folder in bitbucket

I have started using Jenkins recently and there is only scenario where I am stuck. I need to run "Jenkins pipeline" automatically when git push happens for specific folder in master branch. Only if something is added to specific folder, than pipeline should run.
I have already tried SCM with Sparse checkout path, and mentioned my folder, but that's not working.
I am using GUI free style project, I dont know groovy.
I had the same issue and I resolved it by configuring the Git poll.
I used poll SCM to trigger a build and I used the additional behavior of Jenkins Git plugin named "Polling ignores commits in certain paths" > "Included Regions" : my_specific_folder/.*
By the way, using Sparse checkout path allows jenkins to checkout only the folder you mentioned.

Jenkins is checking out the entire SVN repo twice

I have a Jenkins Pipeline setup, and a Jenkins file which has the below content:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Hey'
}
}
}
}
A post commit hook triggers the Jenkins build successfully, and I can see it starting from the Jenkins UI. It states that it is checking out the repo to read from the Jenkins file and it stores the checkout in the workspace#script folder on the server.
Checking out svn https://<svn_server>/svn/Test/Core into C:\Program Files (x86)\Jenkins\jobs\CI_Build\workspace#script to read JenkinsPipeline/Jenkinsfile
Checking out a fresh workspace because C:\Program Files (x86)\Jenkins\jobs\CI_Build\workspace#script doesn't exist
Cleaning local Directory .
After this is complete, I make a change to a file in the repo and the build triggers via the post commit hook happily, but then it tries to checkout the entire code base again into a folder called workspace. I would have expected that the checkout happens once and then the "use SVN update as much as possible" option would kick in and only update the changed files? Or maybe I have the wrong logic?
SVN version - 1.9.7
Jenkins version - 2.84
Jenkins has to know what is in your pipeline script before it knows if it should checkout your code. It is possible that your pipeline says not to check out the code, and you set into a subdirectory and fire off the checkout yourself. Or maybe checkout multiple repos in different places. Until Jenkins sees your Jenkinsfile, it can't know what you want. So it has to checkout the repo once to see your pipeline, then again to do the work.
With git (and maybe some versions of other repo plugins) lightweight or sparse checkouts are supported, so then it only grabs the jenkinsfile instead of the entire repo. I don't think this is a supported option in SVN yet.
Lightweight checkouts are now supported by the SVN plugin, the SVN plugin was updated in version 2.12.0 to add this feature - see https://wiki.jenkins.io/display/JENKINS/Subversion+Plugin.

Jenkins, how to make only specific commits to SVN to trigger a build

I am currently triggering a new Jenkins build whenever a commit to SVN has been made. However, I would like to make another build where our database is deployed only if the Ant script deploying the database OR our SQL scripts has been changed in SVN due to a commit. Is this possible to do in Jenkins?
There is no way to do this out of the box. But you can achieve this through other means.
For the job, you only specify the SVN sources for which you would want to listen. The remaining svn sources can be added to the appropriate location using command line svn methods. Ensure that the command line execution will place and merge the existing sources that jenkins has got. You have to give the right destination options in the svn commands. I myself agree that this is not a very clean way to do, but at least there is a work around for that.
Have two jobs. The first job will be defined only on the required svn sources and you enable the poll option. This should trigger another downstream project which reads all source files. This job should not be polling svn and the actual build execution should be done here.

Resources