Re: Converting to pipeline questions

2019-07-30 Thread Jordan Sokolic
Louis,

To answer your last question, if you decide to use declarative pipelines in 
the end you can use the built-in tools like the declarative directive 
generator and snippet generator. They will provide much the same UI as a 
classic freestyle project which you configure according to your needs, 
spitting out the relevant section which you can then copy/paste into your 
pipeline script. You can read more about how to use these tools at 
https://jenkins.io/doc/book/pipeline/getting-started/#built-in-documentation. 
I've found them to be indispensable when starting out.

To expand on Jeremy's answer, it's possible to embed a scripted section 
into a declarative pipeline. We do this fairly frequently, for example, to 
define custom variables that can be used later in a pipeline. This example 
parses some Git information and saves some variables for later:

stage('Init') {
  steps {
buildName "${params.branch} @${params.commit[0..9]}"
checkout([...])
  
script {
  dir(repo_subdir) {
commit_before_merge = params.commit
author_name  = sh(script: "git log -n 1 ${params.commit} 
--format='%an'", returnStdout: true).trim()
author_email = sh(script: "git log -n 1 ${params.commit} 
--format='%ae'", returnStdout: true).trim()
commit_message  = sh(script: "git log -n 1 ${params.commit} 
--format='%B'",  returnStdout: true)
commit_date = sh(script: "git log -n 1 ${params.commit} 
--format='%ci'", returnStdout: true).trim()
addShortText text: author_email, border: 0, background: 
'lightBlue'
  }
}
  }
}

 Jordan

On Monday, July 29, 2019 at 6:40:56 PM UTC+3, Louis Elston wrote:
>
> 07/17/19 – wrote this…
>
> We are currently using Windows \ Jenkins 2.107.1 (no pipeline), and I am 
> researching going to pipeline. We have a nightly build job, that fetches 
> from repositories, and submits and waits on other jobs. I see 9 jobs 
> running on the same Master node (we only have a master), at the same time. 
> I am not clear on if we should have one Jenkinsfile or multiple 
> Jenkinsfiles. It will not be a multibranch pipeline, as we do not create 
> test branches and then merge back to a master. In the repository we have 
> product1.0 branch, product2.0 branch etc., and build only one branch (the 
> latest one). While I do like the Blue Ocean editor, it is only for 
> MultiBranch pipelines.
>
> Looking for directions and\or examples on how to convert existing Jenkins 
> non-pipeline systems, to pipeline.  I did find this…
> https://wiki.jenkins.io/display/JENKINS/Convert+To+Pipeline+Plugin. It 
> does help a little in that it gives you some converted steps, but cannot 
> convert all the steps, and will give comments in the pipeline script 
> "//Unable to convert a build step referring to...please verify and convert 
> manually if required." There is an option "Recursively convert downstream 
> jobs if any" and if you select that, it appears to add all the downstream 
> jobs to the same pipeline script, and really confuses the job parameters. 
> There is also an option to "Commit JenkinsFile" (if doing declarative). I 
> will play with this some more, but it is not the be all and end all of 
> converting to pipeline, and I still am not sure of whether I should be have 
> one or more scripts.
>
> Added 07/26/19 - Let’s see if I have my research to date correct…
>
> A Declarative pipeline (Pipeline Script from SCM), is stored in a 
> Jenkinsfile in the repository. Every time that this Jenkins job is 
> executed, a fetch from the repository is done (to get the latest version of 
> the Jenkinsfile).
>
> A Pipeline script is stored as part of the config.xml file in the 
> Jenkins\Jobs folder (it is not stored in the repository, or in a separate 
> Jenkinsfile in the jobs folder). There is a fetch from the repository only 
> if you put it in (you do not need to do a repository fetch to get the 
> Pipeline script).
>
> Besides our nightly product build, we also have other jobs. I could create 
> a separate Declarative Jenkinsfile for each of them (JenkinsfileA, 
> JenkinsfileB, etc.) for each of the other jobs and store then in the 
> repository also (in the same branch as the main Jenkinsfile), but that 
> would mean that every one of those additional jobs, to get the particular 
> Jenkinsfile for that job, would also need to do a repository fetch 
> (basically fetching\cloning the repository branch for each job, and have 
> multiple versions of the repository branch unnecessarily downloaded to the 
> workspace of each job).
>
> That does not make sense to me (unless my understanding of things to date 
> is incorrect). Because the main product build does require a fetch every 
> time it is run (to get any possible developer check-ins), I do not see a 
> problem doing Declarative Jenkinsfile for that job. For the other jobs (if 
> we do not leave then for the time being in the 

Re: Jenkins printing every remote branch on all builds [JENKINS-22794]

2019-07-28 Thread Jordan Sokolic
Mark,

That seems to have done the trick. I did in fact have the system property 
set as a Jenkins argument. Moving it from JENKINS_ARGS to JAVA_ARGS in the 
environment file fixed the issue.

Thank you very much!

Jordan

On Saturday, July 27, 2019 at 2:54:15 PM UTC+3, Mark Waite wrote:
>
> Sanjay, your question is unrelated to the original question that Jordan 
> asked.  It is best to use a new thread rather than asking an unrelated 
> question on an existing thread.
>
> Jordan,
>
> I set setting 
> -Dorg.jenkinsci.plugins.gitclient.GitClient.quietRemoteBranches=true on 
> the command line I used to start Jenkins in a docker container and have 
> confirmed that it works as expected.  It needs to be set as a Java option, 
> not as a Jenkins option.
>
> When it is set correctly, the value will be visible in the "System 
> Properties" page that can be displayed from "Manage Jenkins".
>
> [image: System-Properties.png]
>
> On Sat, Jul 27, 2019 at 4:42 AM sanjay mishra  > wrote:
>
>> Hi
>> i am facing 1 error when integrating my Git hub project in Jenkins 
>>
>>
>> Failed to connect to repository : Error performing command: git.exe 
>> ls-remote -h https://github.com/sanjay3933/GITTest.git HEAD  
>>
>> Please help.
>>
>> On Thu, Jul 25, 2019 at 1:55 PM Jordan Sokolic > > wrote:
>>
>>> We are experiencing an issue where Jenkins prints every remote branch in 
>>> our repository to the console in every build. Since we have several 
>>> thousand remote branches, this creates a lot of clutter in console logs.
>>>
>>> Example:
>>>
>>> 10:29:19   > git rev-parse HEAD^{commit} # timeout=10
>>> 10:29:20  Seen branch in repository origin/32_.
>>> 10:29:20  Seen branch in repository origin/337.
>>> 10:29:20  Seen branch in repository origin/359.
>>> 10:29:20  Seen branch in repository origin/4k_.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> 10:29:20  Seen branch in repository origin/API.
>>> (and so on)
>>> 10:29:20  Seen 4,483 remote branches
>>> 10:29:20   > git show-ref --tags -d # timeout=10
>>> 10:29:20  JENKINS-19022: warning: possible memory leak due to Git plugin 
>>> usage; see: 
>>> https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData
>>>
>>> Per JENKINS-22794 we have tried setting 
>>> -Dorg.jenkinsci.plugins.gitclient.GitClient.quietRemoteBranches=true 
>>> in /etc/default/jenkins and confirmed that it is in fact loaded in the 
>>> cmdline, but Jenkins insists on printing all remote branches.
>>>
>>> From the source 
>>> <https://github.com/jenkinsci/git-client-plugin/blob/stable-2.8/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L2202>
>>>  
>>> it's pretty clear that this should work, but it doesn't.
>>>
>>> Jenkins version: 2.176.1 
>>>
>>> OS: Debian 9
>>>
>>> Git client plugin version: 2.8.0
>>>
>>> Thank you for any help.
>>>
>>> Jordan
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Jenkins Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to jenkins...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/692edd0b-18ed-4957-ba20-4a0b28cd78ae%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-users/692edd0b-18ed-4957-ba20-4a0b28cd78ae%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkins...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CANe3u9YQhzrYg5s8RNYLBo1wKfiUX0F%3DLekxD6Z3Q7BwLLp5Dw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/CANe3u9YQhzrYg5s8RNYLBo1wKfiUX0F%3DLekxD6Z3Q7BwLLp5Dw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>
>
> -- 
> Thanks!
> Mark Waite
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8677480f-9ce0-4a51-8706-8eb271fafbba%40googlegroups.com.


Jenkins printing every remote branch on all builds [JENKINS-22794]

2019-07-25 Thread Jordan Sokolic
We are experiencing an issue where Jenkins prints every remote branch in 
our repository to the console in every build. Since we have several 
thousand remote branches, this creates a lot of clutter in console logs.

Example:

10:29:19   > git rev-parse HEAD^{commit} # timeout=10
10:29:20  Seen branch in repository origin/32_.
10:29:20  Seen branch in repository origin/337.
10:29:20  Seen branch in repository origin/359.
10:29:20  Seen branch in repository origin/4k_.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
10:29:20  Seen branch in repository origin/API.
(and so on)
10:29:20  Seen 4,483 remote branches
10:29:20   > git show-ref --tags -d # timeout=10
10:29:20  JENKINS-19022: warning: possible memory leak due to Git plugin 
usage; see: 
https://wiki.jenkins-ci.org/display/JENKINS/Remove+Git+Plugin+BuildsByBranch+BuildData

Per JENKINS-22794 we have tried setting 
-Dorg.jenkinsci.plugins.gitclient.GitClient.quietRemoteBranches=true 
in /etc/default/jenkins and confirmed that it is in fact loaded in the 
cmdline, but Jenkins insists on printing all remote branches.

>From the source 

 
it's pretty clear that this should work, but it doesn't.

Jenkins version: 2.176.1 

OS: Debian 9

Git client plugin version: 2.8.0

Thank you for any help.

Jordan

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/692edd0b-18ed-4957-ba20-4a0b28cd78ae%40googlegroups.com.