jenkinsfile

How can I have a Jenkins pipeline build be triggered from a repository with no jenkinsfile?

老子叫甜甜 提交于 2019-12-05 05:03:24
I have a repository that does not contain a Jenkinsfile - and I have no way of influencing the repository itself. This means I can neither add nor alter any files to or in the repository (In this case, its the Qt repo ). What I want to do is create multiple Jenkinsfiles, that are each configuring and building the Qt library for a different target, or run different additional scripts. All these Jenkinsfiles will be collected in a different repository. Now, my problem is how to create a pipeline job, that gets triggered, as soon as there are changes in the Qt repository, but uses a Jenkinsfile

How do I import a Groovy class into a Jenkinfile?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 05:10:51
How do I import a Groovy class within a Jenkinsfile? I've tried several approaches but none have worked. This is the class I want to import: Thing.groovy class Thing { void doStuff() { ... } } These are things that don't work: Jenkinsfile-1 node { load "./Thing.groovy" def thing = new Thing() } Jenkinsfile-2 import Thing node { def thing = new Thing() } Jenkinsfile-3 node { evaluate(new File("./Thing.groovy")) def thing = new Thing() } You can return a new instance of the class via the load command and use the object to call "doStuff" So, you would have this in "Thing.groovy" class Thing { def

Jenkinsfile build log

二次信任 提交于 2019-12-04 00:05:59
问题 Is there any builtin variable that gives access to the text of the currently executing build? I tried using something like currentBuild.log , currentBuild.buildLog but without any luck. 回答1: Actually it is possible using currentBuild.rawBuild.log or better (not deprecated) currentBuild.rawBuild.getLog(100) (for the last 100 lines), reference: http://javadoc.jenkins-ci.org/hudson/model/Run.html#getLog-int- 回答2: I searched a lot for a solution to analyze the log. use rawBuild was not OK,

How to disable command output in jenkins pipeline build logs

穿精又带淫゛_ 提交于 2019-12-03 14:45:18
问题 I am using Jenkinsfile for scripting of a pipeline. Is there any way to disable printing of executed shell commands in build logs? Here is just a simple example of a jenkins pipeline: node{ stage ("Example") { sh('echo shellscript.sh arg1 arg2') sh('echo shellscript.sh arg3 arg4') } } which produces the following output in console log: [Pipeline] node Running on master in /var/lib/jenkins/workspace/testpipeline [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh [testpipeline]

Jenkins pipeline code auto trigger with multiple repositories through GitHub Organization Folder Plugin

不想你离开。 提交于 2019-12-03 11:42:05
This question is related to the Jenkins job auto trigger with multiple repositories. Defined 3 repo's to checkout in Jenkinsfile. node('slave'){ git clone github.com/owner/abc.git -b ${env.BRANCH_NAME} git clone github.com/owner/def.git -b ${env.BRANCH_NAME} git clone github.com/owner/ghi.git -b ${env.BRANCH_NAME} } Configured Jenkins job using Github organization plugin. In this case my Jenkinsfile is in abc repo and the Jenkins auto trigger is working fine for the abc repo. its not working for other repo's. Is there anyway to define auto trigger for 2 or more repo's? Is there any plugin

try/catch/finally masks Jenkinsfile problems in case of groovy compiler exceptions

三世轮回 提交于 2019-12-03 10:54:43
问题 I have code similar to the one below in my Jenkinsfile: node { checkout scm // do some stuff try { // do some maven magic } catch (error) { stage "Cleanup after fail" emailext attachLog: true, body: "Build failed (see ${env.BUILD_URL}): ${error}", subject: "[JENKINS] ${env.JOB_NAME} failed", to: 'someone@example.com' throw error } finally { step $class: 'JUnitResultArchiver', testResults: '**/TEST-*.xml' } } If the above code fails because of some jenkins-pipeline related errors in the try {

How can I reference the Jenkinsfile directory, with Pipeline?

喜夏-厌秋 提交于 2019-12-03 08:14:28
问题 I have a groovy file, I want to run from the Jenkinsfile. ie. load script.groovy However, I am not sure how I can reference this file if it is stored in the same directory as the Jenkinsfile. I am loading the Jenkinsfile from git. I noticed it creates a folder called workspace@script . It does not place this in the workspace directory. I could hardcode the folder but I am not sure the rules on this and it seems a little redundant to check-out the code again. java.io.FileNotFoundException:

How to disable command output in jenkins pipeline build logs

♀尐吖头ヾ 提交于 2019-12-03 04:33:54
I am using Jenkinsfile for scripting of a pipeline. Is there any way to disable printing of executed shell commands in build logs? Here is just a simple example of a jenkins pipeline: node{ stage ("Example") { sh('echo shellscript.sh arg1 arg2') sh('echo shellscript.sh arg3 arg4') } } which produces the following output in console log: [Pipeline] node Running on master in /var/lib/jenkins/workspace/testpipeline [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh [testpipeline] Running shell script + echo shellscript.sh arg1 arg2 shellscript.sh arg1 arg2 [Pipeline] sh [testpipeline]

try/catch/finally masks Jenkinsfile problems in case of groovy compiler exceptions

我只是一个虾纸丫 提交于 2019-12-03 02:26:13
I have code similar to the one below in my Jenkinsfile: node { checkout scm // do some stuff try { // do some maven magic } catch (error) { stage "Cleanup after fail" emailext attachLog: true, body: "Build failed (see ${env.BUILD_URL}): ${error}", subject: "[JENKINS] ${env.JOB_NAME} failed", to: 'someone@example.com' throw error } finally { step $class: 'JUnitResultArchiver', testResults: '**/TEST-*.xml' } } If the above code fails because of some jenkins-pipeline related errors in the try { } (e.g. using unapproved static method) the script fails silently. When I remove the try/catch/finally

How do I implement a retry option for failed stages in Jenkins pipelines?

风格不统一 提交于 2019-12-03 01:04:35
问题 I have a Jenkinsfile with multiple stages and one of them is in fact another job (the deploy one) which can fail in some cases. I know that I can made prompts using Jenkinsfile but I don't really know how to implement a retry mechanism for this job. I want to be able to click on the failed stage and choose to retry it. 回答1: You should be able to combine retry + input to do that Something like that stage('deploy-test') { try { build 'yourJob' } catch(error) { echo "First build failed, let's