Re: Is multiple triggers an option?

2022-02-25 Thread Gianluca


Hi,

We have the same requirements and we have a big pipeline that runs 
different things depending of the trigger and we have nightly CI builds.

 

We use the conditional “when” to identify the trigger and run some portion 
of the pipeline depending of where it comes from:

 

stage('Deploys') {
when {
beforeAgent 
*true *anyOf {
triggeredBy 'UpstreamCause'
triggeredBy 'BuildUpstreamCause'
triggeredBy 'UserIdCause'
}
}

 

The above is a portion of the pipeline we only want to build when triggered 
by an upstream job or someone manually run it.

This exclude all webhooks related to push code to our repository, just to 
mention one.

 
stage('Setup') {
when {
beforeAgent 
*true *anyOf {
triggeredBy 'GitHubPullRequestCommentCause'
}
} 

 

The above is a part of the pipeline we want to run only when someone 
commented on GitHub and not on other webhooks.

 

And finally:

 
triggers {
cron(branch.isMaster() ? 'H 0 * * *' : '')
} 

 

We use the triggers option to setup nightly builds for the master branch 
only.

 

Hope that this is what you are looking for,

Cheers,

Gianluca.

On Friday, 25 February 2022 at 16:42:58 UTC rsap...@gmail.com wrote:

> We have a huge pipeline that is currently set with a webhook trigger 
> defined in a pipelineTriggers section in the properties section.  However, 
> sometimes we would like some of these jobs to ONLY run nightly CI builds.  
> I'm trying to avoid having a second version of this huge pipeline script 
> where the only difference is the piplineTrigger section.
> In a perfect world I'd have a Boolean parm for CI that when checked, 
> the job used a cron type trigger and when unchecked, it used the web hook 
> trigger... but I have seen anything like that.
>
> any help would be appreciated.
>
> Thanks,
>
> Rusty
>

-- 
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/44867921-e7a8-4202-a596-6a1c6d77cc94n%40googlegroups.com.


How to hide/remove some tags from Jenkins builds?

2021-09-16 Thread Gianluca
Hi all,
some times ago we enabled the discovery of tags in our GitHub Organization 
project on Jenkins and now a new tab with tags and builds done by checking 
out the tags is availabe.

Although, after a while, we have now that tag full of a lot of tags we are 
not building anymore because are old or irrelevant.

Is there a way to set Jenkins to discover only certain tags based on a 
patter name, similar to branches?
If not what are my alternatives to hide some tags from that tab?

Thanks,
Gianluca.

-- 
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/f00dd798-d394-40eb-931d-d87040f8307bn%40googlegroups.com.


Re: Fwd: How to run upstream and downstream jobs on same executor

2021-04-05 Thread Gianluca Massera

Hi,

From what I know, a job will keep an executor busy till it completes.

Hence, if an upstream job needs to do something after a downstream 
completes, then Jenkins needs two executors.


Otherwise, if an upstream job doesn't need to anything after a 
downstream completes, then you trigger a downstream with wait options 
set to false and if there is only one executor Jenkins will queue the 
downstream job till the upstream completes and the executor will be free 
to run something else.


Is it clear?

Also, "waiting for something" even though doesn't need much CPU still 
needs some processing power, hence you need an executor, hence is not 
occupied unnecessarily ... it's occupied to do what you asked for: "wait 
for something" ;-)


Hope that helps.

Cheers,

Gianluca.


On 05/04/2021 17:18, kamthe kirtee wrote:

Hi,

My question is if upstream job is running on executor 1 and when 
downstream job is triggered, that should run on executor 1 or executor 2


As soon as downstream job started running, upstream job should not be 
running on any of the  executor.


Beacuse I don't want upstream job to wait for the downstream job to 
complete

 and also  not to occupied executor unnecessarily.

Thanks


On Mon, 5 Apr, 2021, 8:49 pm Gianluca Massera, <mailto:gmax...@gmail.com>> wrote:


Hi,

from what I know, it's not achievable. When a job is waiting for a
downstream to complete, it keeps an executor occupied. So, the
downstream job needs to run on a different executor.

But, frankly, that seems more of https://xyproblem.info/
<https://xyproblem.info/> :-)

So, what is your problem? what do you need?

Cheers,

Gianluca.


On 05/04/2021 12:36, kamthe kirtee wrote:


-- Forwarded message -
From: *kamthe kirtee* mailto:kamthekirte...@gmail.com>>
Date: Mon, 5 Apr, 2021, 4:36 pm
Subject: How to run upstream and downstream jobs on same executor
To: mailto:jenkinsci-users%2bsubscr...@googlegroups.com>>


Hi team,

Suppose in jenkins I have 1 slave  and in that slave I have 1
executor
Also I have one upstream job and one downstream job

My question is:
If an upstream job is running on executor 1,  and after that my
downstream job is starting on the same executor at the same time,
& I want upstream job to go aside/queue  untill the downstream
job is over.

Once the downstream job is over, the paused upstream job should
again resume start running on the same executor.

So how We can achieve this?  Because I don't want to increase the
number of executors

Can you please guide me for the same?

Thanks
-- 
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
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGieWSsj%3DmAtLQEyuOkn0h5Y_q%2BGpf1oEZ%3DMKYfYS20mEw%40mail.gmail.com

<https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGieWSsj%3DmAtLQEyuOkn0h5Y_q%2BGpf1oEZ%3DMKYfYS20mEw%40mail.gmail.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/jenkinsci-users/60c42944-94fb-b406-65d2-e5f905e81af6%40gmail.com

<https://groups.google.com/d/msgid/jenkinsci-users/60c42944-94fb-b406-65d2-e5f905e81af6%40gmail.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com 
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGiVtQ5p%3DZGdNwaFTPXE6XJxVuEUvkXiJgv%3DF4hAGvb0vA%40mail.gmail.com 
<https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGiVtQ5p%3DZGdNwaFTPXE6XJxVuEUvkXiJgv%3DF4hAGvb0vA%40mail.gmail.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3fd8068d-010e-a5e7-3992-ab26dd6721ed%40gmail.com.


Re: Fwd: How to run upstream and downstream jobs on same executor

2021-04-05 Thread Gianluca Massera

Hi,

from what I know, it's not achievable. When a job is waiting for a 
downstream to complete, it keeps an executor occupied. So, the 
downstream job needs to run on a different executor.


But, frankly, that seems more of https://xyproblem.info/ :-)

So, what is your problem? what do you need?

Cheers,

Gianluca.


On 05/04/2021 12:36, kamthe kirtee wrote:


-- Forwarded message -
From: *kamthe kirtee* <mailto:kamthekirte...@gmail.com>>

Date: Mon, 5 Apr, 2021, 4:36 pm
Subject: How to run upstream and downstream jobs on same executor
To: <mailto:jenkinsci-users%2bsubscr...@googlegroups.com>>



Hi team,

Suppose in jenkins I have 1 slave  and in that slave I have 1 executor
Also I have one upstream job and one downstream job

My question is:
If an upstream job is running on executor 1, and after that my 
downstream job is starting on the same executor at the same time, & I 
want upstream job to go aside/queue  untill the downstream job is over.


Once the downstream job is over, the paused upstream job should again 
resume start running on the same executor.


So how We can achieve this?  Because I don't want to increase the 
number of executors


Can you please guide me for the same?

Thanks
--
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 
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGieWSsj%3DmAtLQEyuOkn0h5Y_q%2BGpf1oEZ%3DMKYfYS20mEw%40mail.gmail.com 
<https://groups.google.com/d/msgid/jenkinsci-users/CAD0fyGieWSsj%3DmAtLQEyuOkn0h5Y_q%2BGpf1oEZ%3DMKYfYS20mEw%40mail.gmail.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/60c42944-94fb-b406-65d2-e5f905e81af6%40gmail.com.


Re: Restart from stage

2021-03-23 Thread Gianluca Massera

Hi,

I use the following code to walk through all stages of the pipeline for 
a different reason but it could be an hint for you to achieve your goal:


WorkflowRun run = prevBuild.getRawBuild()
NodeGraphBuilder graphBuilder = 
NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run);

 def flowNodes = graphBuilder.getPipelineNodes()

 for (Iterator iterator = flowNodes.iterator(); iterator.hasNext();) {
    def node = iterator.next()
    if (node.getDisplayName() == stageName) {
    return node.getStatus().getResult() == BlueRunResult.SUCCESS
    }
 }

A stage is a pipeline node, but there are nodes that are not stages. So, 
you probably need to dig into internal code to find out how to identify 
only the stages.


Cheers,

Gianluca.


On 23/03/2021 00:22, unlimh...@gmail.com wrote:

Thanks, Gianluca.

Your professional help, as always, is very operational and useful!
Thanks to you, I have implemented the ability to run from any Stage, but I would also 
like to form in "Active Choices Reactive Parameter" plugin automatic list from 
the names of Stages {}, which I have in PiPleine. Are there ready examples of code to 
obtain a list of names of all Stages from code pipeline (to select the stage I need 
before building the pipeline) ?



Hi what-ever-is-your-name-:-)
I use the "when" block to run only specific stages depending on the parameters: 
https://www.jenkins.io/doc/book/pipeline/syntax/#when
I hope that fits your case too.
Cheers,
Gianluca.
On 22/03/2021 22:47, unlimh...@gmail.com wrote:

Are there any examples of the implementation of running a pipeline from a particular 
stage? I need to set in the pipeline parameters to make it run on a specific node and 
from a specific stage. If there are no questions with the first one, what are the 
easiest options to pass  from which to run the pipelines, skipping 
the previous ones?
Something similar I found here but it's not enough for me to implement this 
task:
https://github.com/SAP/jenkins-library/blob/master/vars/pipelineRestartSteps.groovy

https://issues.jenkins.io/browse/JENKINS-52391

Thanks!



--
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/1834c4d1-50d7-1b0d-ffcb-abb53753ab83%40gmail.com.


Re: Restart from stage

2021-03-22 Thread Gianluca Massera

Hi what-ever-is-your-name-:-)

I use the "when" block to run only specific stages depending on the 
parameters: https://www.jenkins.io/doc/book/pipeline/syntax/#when


I hope that fits your case too.

Cheers,

Gianluca.

On 22/03/2021 22:47, unlimh...@gmail.com wrote:

Are there any examples of the implementation of running a pipeline from a particular 
stage? I need to set in the pipeline parameters to make it run on a specific node and 
from a specific stage. If there are no questions with the first one, what are the 
easiest options to pass  from which to run the pipelines, skipping 
the previous ones?
Something similar I found here but it's not enough for me to implement this 
task:
https://github.com/SAP/jenkins-library/blob/master/vars/pipelineRestartSteps.groovy

https://issues.jenkins.io/browse/JENKINS-52391

Thanks!



--
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/4d48f1ee-e607-f5a8-9f85-57196d5ae5f4%40gmail.com.


Re: Execute a function from post actions in Jenkinsfile

2020-12-20 Thread Gianluca Massera

Hi,

I'm not sure I understood your issue on calling functions. Maybe there 
is only a bit of confusion about the Jenkins pipeline syntax.


From what you said, you are already calling functions into the post 
sections: "cleanWs()" is a function, "emailext body: ... " is a function.


So, maybe you are confused by the fact Jenkins syntax in post doesn't 
allow something like:


post {

    aFunction()

}

So, nope, the above doesn't work. Because the "post" syntax are blocks 
based on the result of the pipeline and you actually listed all possible 
options:


"always, changed, fixed, regression, aborted, success, unsuccessful, 
unstable, failure, notBuilt, cleanup"


And if I understood, you want to call a function that does different 
things depending on the pipeline result ... then, you need to used "always":


post {

   always {

   aFunction(BUILD_RESULT)

   }

}

And then the function will do different things depending of the 
BUILD_RESULT value:


if (BUILD_RESULT == "SUCCESS") {

   message = "Pipeline failed"

} else {

   message = "Pipeline ... whatever"

}

I hope that helps.

Cheers,

Gianluca.


On 20/12/2020 17:35, Kernel Panic wrote:


Hello there.

I looking for an elagant way to execute code from the post {} section,
I want to write a clean Jenkinsfile and execute code from shared 
libraries as

posible.
In the post section I have the tipical  clean working directory like this:

always {
  cleanWs()
    }

I also send notification based on pipeline completion, I mean, aobrted 
, failed,
changed and so on,  but I want to call a function to do that, I want 
to remove the

email code I have something like this:

emailext body: 'Check console output at $BUILD_URL to view the 
results. \n\n ${CHANGES} \n\n - 
\n${BUILD_LOG, maxLines=50, escapeHtml=false}',

    to: "${EMAIL_ADDRESSES}",
    subject: 'Pipeline Execution  Failed: $PROJECT_NAME - 
#$BUILD_NUMBER'


The problem seems that from the post you only can call an expected 
function of
type: always, changed, fixed, regression, aborted, success, 
unsuccessful, unstable, failure, notBuilt, cleanup.


Is there another way to accomplish this to write a more clean Post 
section?



Thanks
Regards

--
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 
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/ea74e553-88a7-4925-ade2-27462aaceab1n%40googlegroups.com 
<https://groups.google.com/d/msgid/jenkinsci-users/ea74e553-88a7-4925-ade2-27462aaceab1n%40googlegroups.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/7379987a-7062-0c47-d447-98f6a6999142%40gmail.com.


Re: SSL native (self) Jenkins

2020-12-11 Thread Gianluca
Hi,
let’s separate two completely different tasks of what you are trying to achieve:
1) Configure Jenkins server to serve itself over SSL / HTTPS
2) Use a certificate that your browser recognise as valid

The documents you listed, tell you how to do point 1) and in general is left to 
you (or to other guides) how to do point 2)

Now, from the error you see on the browser, “CERT_AUTHORITY_INVALID”, I’m 
pretty sure that you achieved 1)
So, you actually did it !!

But maybe you don’t know exactly what the error means. So, I’ll try to details 
to best of my knowledge (I’m not an expert of certificate authorities):
- the browser tries to reach your Jenkins over port 443 (HTTPS)
- Jenkins reply correctly and the browser is happy and they start to establish 
an SSL connection between them (that means they successfully exchanged the SSL 
certificate and they can encrypt the connection)
- But the browser wants to be sure that the certificate has been made by some 
“known” trusted authority … let’s think of it like a known valid institution 
that produce valid certificates
- … but when it looks inside the certificates, it can’t find a certificate 
authority that knows … and then, for safety, it stops the communication and 
raise an error saying that it can’t “trust” the certificate because it’s not 
produced by an authority that it knows.

So, Jenkins is setup correctly and you did everything correctly on configure it.
The last bit that remains for you is to get a “real” valid certificate from a 
real valid certificate authority … if you can’t, then you can’t avoid the 
browser giving the CERT_AUTHORITY_INVALID error.

I hope that’s clear.

Cheers,
Gianluca.

P.S.: The fact Jenkins does not have access to the Internet, doesn’t prevent 
you to get a valid certificate from a valid authority, like letsencrypt or 
other certificate authorities like Comodo SSL, and so on.
We have many servers in our infrastructure without access to Internet but with 
valid certificate from Comodo SSL and LetsEncrypt



> On 11 Dec 2020, at 20:42, unlimh...@gmail.com wrote:
> 
> Please help with the working instructions for installing SSL (https) on 
> Jenkins.
> Is it possible to install an SSL certificate on Jenkins without a reverse 
> proxy (nginx)?
> 
> I tried these instructions below, but they didn't help (the certificate 
> doesn't work) and I get in the browser:
> 
> Your connection is not private
> NET::ERR_CERT_AUTHORITY_INVALID
> 
> p.s. My network with Jenkins does not have access to the Internet, so 
> solutions in letsencrypt and similar will not work for me.
> 
> links:
> https://wiki.jenkins.io/pages/viewpage.action?pageId=135468777 
> <https://wiki.jenkins.io/pages/viewpage.action?pageId=135468777>
> https://mohitgoyal.co/2017/02/08/securing-your-jenkins-environment-and-configure-for-auditing/
>  
> <https://mohitgoyal.co/2017/02/08/securing-your-jenkins-environment-and-configure-for-auditing/>
> https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx 
> <https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+Nginx>
> https://agirlhasnona.me/ops-tutorial-ssl-jenkins/ 
> <https://agirlhasnona.me/ops-tutorial-ssl-jenkins/>
> https://jansipke.nl/enable-https-jenkins/ 
> <https://jansipke.nl/enable-https-jenkins/>
> 
> Thanks!
> 
> -- 
> 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 
> <mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/459881610.20201211234224%40gmail.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/459881610.20201211234224%40gmail.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6422CCE5-7F24-4671-A5D7-9DE43A47721E%40gmail.com.


Re: String interpolation in sh command with credentials and (shared lib) function call

2020-11-17 Thread Gianluca
Somethings said are correctly … somethings said are wrong.
I’ll try to summarise pointing to the lines in your pipeline and explain what’s 
wrong and how to fix:

Single quoted string are literals. They never get interpolated and passed as 
they are.
So, in your case:

> sh '${JAVA_HOME}/bin/java -version' // single quotes - this works fine!

Work … not because ${JAVA_HOME} is interpolated by Jenkins … but because for an 
unfortunate coincidence … ${JAVA_HOME} is a correct bash syntax for reference 
an environment variable in bash and get expanded correctly.
DO NOT confuse Jenkins pipeline environment variable that exists only in the 
pipeline context with the BASH environment variable that exists in the shell 
when “sh” is executed.
Now, also take into account that Jenkins also creates a corresponding BASH 
environment variable for each pipeline environment variable.
So, what in Groovy double-quoted string like “${env.GEN_USR}” get expanded 
using the value of the Jenkins environment variable GEN_USR, but if you want to 
let bash expand the environment variable then you have to pass '${GEN_USR}’ … 
in single-quoted string … or … you need to escape “$” in double-quoted string 
to avoid that Groovy does the interpolation instead of bash.

Your multi-line command suffer from the fact somethings need to be expanded by 
Groovy and something else need to be expanded by BASH, so you need to split in 
different string and concatenate or escape $:

>  sh script: '''
> ${mvnCommand(m2RepoIdentifier)}\
This is a Jenkins function … so need to be expanded by Groovy and it’s in the 
double-quoted string… so far so good
>  -f proj-reactor/pom.xml\
>  -P GenerateStorables -DdeployAtEnd=true\
>  -Dproj.build.generatefromdb.url=${jdbcUrlNoData()}\
That is the same … so it’s good
>  -Dproj.build.generatefromdb.user=${GEN_USR}\
That’s the problem. You are using “withCredentials” and that command only 
creates BASH environment variable … and you are letting Groovy do the expansion 
but GEN_USR doesn’t exist into Jenkins pipeline … and neither env.GEN_USR … the 
only one that exist is the BASH environment variable and you have to let bash 
expand … so you need to escape $ to pass as it is to BASH:

-Dproj.build.generatefromdb.user=\${GEN_USR}\

>  -Dproj.build.generatefromdb.password=${GEN_PASSWD}\
Same as above… it’s a BASH environment variable
>  clean ${mvnBuildGoal} pmd:pmd pmd:cpd\
That is probably a Groovy variable but I’m not entire sure.
>   '''


I hope that helps.

As suggestion, try to split and use a mix of double-quoted and single-quoted so 
you avoid escaping:

  sh script: 
"${mvnCommand(m2RepoIdentifier)} “ +
 '-f proj-reactor/pom.xml ‘ +
 '-P GenerateStorables -DdeployAtEnd=true ‘ +
 "-Dproj.build.generatefromdb.url=${jdbcUrlNoData()}” +
 '-Dproj.build.generatefromdb.user=${GEN_USR} ‘ +
 '-Dproj.build.generatefromdb.password=${GEN_PASSWD} ‘ +
 'clean ${mvnBuildGoal} pmd:pmd pmd:cpd'


Cheers,
Gianluca.


> On 17 Nov 2020, at 20:45, JonathanRRogers  wrote:
> 
> I don't think you've read the Jenkins pipeline documentation correctly. 
> String interpolation is performed by Groovy. Jenkins doesn't add any 
> interpolation behavior. Jenkins will always treat single-quoted strings as 
> simple literals. The "sh" step calls a shell which can do its own variable 
> expansion, which is the approach recommended for passing credentials to 
> external commands.
> 
> Your multi-line sh step includes calls to "mvnCommand()" and 
> "jdbcUrlNoData()". Unless those are shell functions, you're unlikely to get 
> the results you want.
> 
> On Tuesday, November 17, 2020 at 10:41:51 AM UTC-5 st.mail...@gmail.com wrote:
> Thanks Dirk, but that does not solve my problem, I'm still stuck.
> I think that my question boils down to why the multi-line sh command below 
> does not work?
> According to 
> https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation 
> <https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#string-interpolation>
> single-quoted strings should be interpolated by Jenkins (instead of using 
> Groovy string interpolation). I would assume this applies
> to both variables (e.g. GEN_USR below) and method calls returning a string 
> (e.g. jdbcUrlNoData() below)?
> 
> withCredentials([usernamePassword(credentialsId: 'credentialsGenerateFromDb',
>usernameVariable: 'GEN_USR',
>passwordVariable: 'GEN_PASSWD')]) {
>String m2RepoIdentifier = "${env.BRANCH_NAME}_${env.BUILD_

Re: Get build number of spawned job?

2020-09-16 Thread Gianluca
You can pass parameters to downstream jobs (Jenkins terminology for the 
jobs started via "build job") with the BUILD_ID of the upstream job 
(Jenkins terminology for the job that called "build job"):

build job: "CommonPipeline", wait: true, parameters: [ [name: UPSTREAM_ID, 
value: env.BUILD_ID], ... ]

Cheers,
Gianluca.

Il giorno mercoledì 16 settembre 2020 alle 21:47:26 UTC+1 zil...@gmail.com 
ha scritto:

> IOW, both Pipeline1 and Pipeline2 jobs have this
>
> String buildNum = 
> copyArtifacts projectName: 'CommonPipeline',
>   fingerprintArtifacts: true,
>   filter: 'SomeFile.yml'
>   selector: specific(buildNumber)
>
> What do I put in the  ?
>
> thanks,
> Chris
> 
> Reply all
> Reply to author
> Forward
>
>
> On Wednesday, September 16, 2020 at 4:37:48 PM UTC-4 zil...@gmail.com 
> wrote:
>
>> If I spawn a job in jenkins, like this
>>
>> Pipeline1:
>> build job: "CommonPipeline",
>>   wait: true
>>
>> You see this in the Jenkins console for Pipeline1
>>
>> Scheduling project: CommonPipeline
>> Starting building: Starting build CommonPipeline #100
>>
>> Now if I start another pipeline at the same time Pipeline1 is running
>>
>> Pipeline2:
>> build job: "CommonPipeline",
>>   wait: true
>>
>> You see this in the Jenkins console for Pipeline2
>>
>> Scheduling project: CommonPipeline
>> Starting building: Starting build CommonPipeline #101
>>
>> In each Pipeline1 and Pipeline2 jobs, how can I get the corresponding 
>> build numbers that they spawned for CommonPipeline? I'm asking because 
>> CommonPipeline archives artifacts for Pipeline1 and Pipeline2, and I need 
>> to get the artifact for their corresponding spawned CommonPipeline job#. Is 
>> this possible?
>>
>> Hope that makes sense.
>>
>> Thanks,
>> Chris
>>
>>
>>

-- 
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/1889-f831-4446-8498-80c5034d0aa1n%40googlegroups.com.


Re: Share files between pipelines?

2020-09-16 Thread Gianluca
The error is very verbose.
So ... or the project name is incorrect ... or the user running Pipeline2 
doesn't permission to see "Pipeline1".

You can check the project name by looking at the Jenkins user interface for 
"Full project name:  "
See screenshot.

Ah ... remember that you have to escape the "/" with "%2F" in the pipeline 
code.


Il giorno mercoledì 16 settembre 2020 alle 16:48:35 UTC+1 zil...@gmail.com 
ha scritto:

> I posted this in Stackoverflow but i thought I'd post it here too, since 
> this is a Jenkins specific group
>
>
> https://stackoverflow.com/questions/63923156/sharing-files-between-jenkins-pipelines
>
>  I want to share a file between two different pipelines, running on 2 
> different nodes.
>
> I tried to use the Copy Artifacts plugin like so
> Pipeline1:
> node {'linux-0') { 
>   stage("Create file") { 
>  sh "echo \"hello world\" > hello.txt"
>  archiveArtifacts artifact: 'hello.txt', fingerprint: true
>}
>  }
>
> Pipeline2:
> node('linux-1') { 
>   stage("Copy form first pipeline") { 
> copyArtifacts projectName: 'Pipeline1',
>   fingerprintArtifacts: true,
>   filter: 'hello.txt' 
>}
> }
>
> and I get the following error for Pipeline2
> ERROR: Unable to find project for artifact copy: Pipeline1 This may be due 
> to incorrect project name or permission settings; see help for project name 
> in job configuration. Finished: FAILURE
>
> What am I missing?
>

-- 
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/c01c68fd-81fe-4d10-9ca5-2709323512fdn%40googlegroups.com.


Re: Best approach for trigger build only new added branches when scan multi-branch pipeline

2020-09-16 Thread Gianluca
I can see some ways to achieve that.
You can look at the "triggeredBy" option to use in the "when" block to 
avoid build the pipeline is not triggered but what you want.
For example, we do this:

when {
  anyOf {
 triggeredBy 'UpstreamCause'
 triggeredBy 'UserIdCause'
  }
}

Because we don't want that pipeline to run on scan multi-branch, push 
commits and other things.

If there isn't any trigger that fits your case, then you can still create a 
little Groovy script that returns a boolean and use inside the when anyway 
like that:

when {
  expression {
FSTChangePatterns.any{pattern -> sideCars.areFilesChanged(pattern)}
  }
}

I don't know other ways to achieve what you want but they may be there are.

Cheers,
Gianluca.
Il giorno mercoledì 16 settembre 2020 alle 10:07:39 UTC+1 
banthit...@gmail.com ha scritto:

> Dear folks,
>
> I have a limited resources Jenkins server and a bunch of multi-branch 
> pipelines which are poll from GitLab repositories (scripted jenkins 
> pipeline ).
>
> Then I've noticed that my Jenkins usually crash by run out of memory when 
> someone click on scan multi-branch and its triggers build multiple 
> pipelines at the same time.
>
> My desired is only trigger automatically build the pipeline for only new 
> added branch.
> Right now I have master, hot-fix, release, support, develop and loads of 
> features branches.
> (The feature branches are frequently added)   
>
> Then I searched for a solution, '*Suppress automatic scm triggering'  *might 
> help me. But it will block only the specific branch that we've set in the 
> Jenkins's configuration rather than build new whatever added branch (it can 
> be feature, support or any custom created branches). I don't want to strict 
> the build with a specific branch.
>
> So I came here for find the best approach for this issue. Any suggestions 
> are welcomed
>
> Thanks!
>

-- 
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/3588060c-42a5-4bfe-bc89-1fe101cb84e7n%40googlegroups.com.


Re: Bash Shell output as Jenkins Choice Parameter

2020-09-15 Thread Gianluca
Hi Kenny,
I think you still need to get the output from shell script to groovy and 
then parse it.
The "sh" command has a parameter to return the stdout of the script.

So, starting from the Groovy script you mentioned ... then I would remove 
all code related to "cmd.execute" and I will change with a line that call 
the sh command:

sout = sh( script: "./script.sh", returnStdout: true )

I would make sure the script.sh returns a JSON ... and then continue from 
line 31 of the example script as it is.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 23:43:00 UTC+1 kenny...@gmail.com 
ha scritto:

> I'm running Jenkins 2.251 on Ubuntu.
> I have a shell script (script.sh) that outputs a list: 
> $ ./script.sh
> [item1,item2,item3]
>
> In my freestyle project I've added a build step that executes script.sh, 
> and I see the output in the build log just like the above example. I don't 
> care if the final project is freestyle, but that worked to get me to this 
> point.
>
> Now, I want to use this list as the input to a Choice parameter so it 
> creates a dropdown chooser with the items in the list. I've marked the 
> project as parameterized and added a Choices parameter but there is no 
> linkage between the list above and the Choices parameter. I would like to 
> know how to use the output from script.sh as the input to the Choices 
> dropdown.
>
> I found a groovy example here that *kinda *does what I want but I don't 
> need to rewrite the groovy code to produce the list, it's all done in 
> script.sh:
> https://ruepprich.com/jenkins-populate-choice-parameter-from-shell-command/
>
> Any help is appreciated!
>
> Thanks,
>
> -Kenny Cason
>

-- 
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/08a58a9b-8283-4d01-9402-f81baef34678n%40googlegroups.com.


Re: How to trigger a job at a certain time in Jenkins pipeline?

2020-09-15 Thread Gianluca
Yes, it explains.

I would suggest to use intermediate artifacts / published files to use on 
the "Deploy" job to know what to do instead of trigger that from "Build" 
job.
(I'm calling "Build" the one that runs on mid-day and "Deploy" the one that 
runs at "H 21 * * 1")

So, in my suggestion the flow would be that "Deploy" job will be triggered 
by Jenkins base on "cron" trigger and when it runs, it will checks if there 
is a list of thing to deploy produced by "Build" job.
You can do the latter in many ways. One that's part of the Jenkins core is 
archiveArtifacts: https://www.jenkins.io/doc/pipeline/steps/core/
So, "Build" job will archive, let's say a JSON listing all microservices 
that need to be deployed. Then "Deploy" job will look for that list and if 
it's not empty, it will deploy all those listed microservices.

I hope that helps.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 16:05:46 UTC+1 zil...@gmail.com ha 
scritto:

> Thanks for responding Gianluca.
>
> So I have a Jenkins job that builds production code mid-day, but does NOT 
> deploy it. We have a a separate deployment job that's cron'ed at "H 21 * * 
> 1" to deploy the code built by the mid-day build job
>
> Part of the mid-day build is to check if certain microservices' versions 
> need to be deployed to production as well, and I'd like for it to trigger a 
> job for each microservice it needs to deploy at "H/30 20 * * 1". IOW the 
> needed microservices can not be deployed mid-day either.
>
> Hope that explains it.
> On Tuesday, September 15, 2020 at 10:47:34 AM UTC-4 Gianluca wrote:
>
>> From what I know that's specific thing is not possible.
>> And to be honest, it's quite strange as well.
>>
>> Maybe if you explain us why are you trying to do that, we could suggest 
>> alternatives that are possible in Jenkins.
>>
>> Cheers,
>> Gianluca.
>>
>>
>> Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 zil...@gmail.com 
>> ha scritto:
>>
>>> I see this, but I don't understand how to implement it for my use case.
>>>
>>> https://www.codependentcodr.com/scheduled-builds-in-jenkins-scripted-pipelines.html
>>>
>>> I want JobA to trigger JobB, but at a certain time. I do this now
>>>
>>> *Step in JobA to trigger JobB*
>>> build job: JobB,
>>>   wait: true
>>>
>>> ...but I wish I can do this (for illustration only, the cron option does 
>>> not exist of course)
>>>
>>> *Step in JobA to trigger JobB to run around 9:00pm ET*
>>> build job: JobB,
>>>   cron: "H 21 * * 1",
>>>   wait: true
>>>
>>> Any ideas? Thanks!
>>>
>>

-- 
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/32d9e958-5e42-431d-88eb-fd944435a0ccn%40googlegroups.com.


Re: How to trigger a job at a certain time in Jenkins pipeline?

2020-09-15 Thread Gianluca
>From what I know that's specific thing is not possible.
And to be honest, it's quite strange as well.

Maybe if you explain us why are you trying to do that, we could suggest 
alternatives that are possible in Jenkins.

Cheers,
Gianluca.


Il giorno martedì 15 settembre 2020 alle 15:40:20 UTC+1 zil...@gmail.com ha 
scritto:

> I see this, but I don't understand how to implement it for my use case.
>
> https://www.codependentcodr.com/scheduled-builds-in-jenkins-scripted-pipelines.html
>
> I want JobA to trigger JobB, but at a certain time. I do this now
>
> *Step in JobA to trigger JobB*
> build job: JobB,
>   wait: true
>
> ...but I wish I can do this (for illustration only, the cron option does 
> not exist of course)
>
> *Step in JobA to trigger JobB to run around 9:00pm ET*
> build job: JobB,
>   cron: "H 21 * * 1",
>   wait: true
>
> Any ideas? Thanks!
>

-- 
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/26e5a780-5c25-4a5d-859a-d0133b07e3b2n%40googlegroups.com.


Re: Starting mutiple process

2020-09-11 Thread Gianluca
We run dozens of processes from different folders in our pipeline. So, 
there should be something in our pipeline definition that prevents you from 
that.
Can you please give us more details about your pipeline so we can help?

Cheers,
Gianluca.

Il giorno sabato 12 settembre 2020 alle 06:28:47 UTC+1 sravan ha scritto:

> Hi 
> I am trying to start the same process from folder A and folder B. when 
> jenkins starts process from folder A it looks good but when it starts the 
> process from folder b it stops the process of folder A . I need the two 
> process. How can I keep the process active  from folder A and B
>
> Any help is appreciated 
>
> Thanks,
> Sravan
>

-- 
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/f18677c4-e46b-4e85-bc3c-71ee6bbc2fb6n%40googlegroups.com.


Re: How to share (non-secret) variables between jobs

2020-09-09 Thread Gianluca
You could maybe 
use https://www.jenkins.io/doc/book/pipeline/shared-libraries/ and load 
those variable from a global shared library and used inside the pipelines.


Il giorno giovedì 10 settembre 2020 alle 01:46:51 UTC+1 ashish...@gmail.com 
ha scritto:

> Dear All,
>
> We have a bunch of jobs which will use some common variables like user 
> names, urls etc (which are not secrets or credentials). Is there a way (or 
> plugin maybe) to share these variables between jobs (something like 
> credentials plugin for secrets).
>
> TIA,
> Ashish
>

-- 
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/39f6c3f8-2880-445c-ac84-3cedb963d72an%40googlegroups.com.


Re: Webhook should ignore changes in specific directory

2020-09-08 Thread Gianluca
The only way I found to achieve that it's using "when" expression of 
"stage" with a function I've built to check if thing changed.

when {
expression {
FSTChangePatterns.any{pattern -> sideCars.areFilesChanged(pattern)}
}
}

Where the areFilesChanged is:

// There is a bug in the changeset Jenkins command: 
https://issues.jenkins-ci.org/browse/JENKINS-44849
// ---
// It returns true if the list of changed files in the PR matches the grep 
pattern passed
// NOTE: it will always returns true in case the build is running on a 
branch and not on a PR
// because we always want to run a full pipelines on master, release and 
feature branches
def areFilesChanged(grepPattern) {
if (!env.CHANGE_TARGET) return true
sh(
// NOTE: the triple-dot are necessary to get the same diff result shown by 
GitHub PRs
script: "git diff origin/${env.CHANGE_TARGET}...HEAD --name-only | grep 
'${grepPattern}'",
returnStatus: true
) == 0
}

Cheers,
Gianluca.

Il giorno martedì 8 settembre 2020 alle 10:01:21 UTC+1 yogesh...@gmail.com 
ha scritto:

> Hi All,
>
> I am using webhook to trigger my declarative pipeline job.
> I  want to ignore the directory in my github project, whenever there is 
> changes/commits to particular directory it should not trigger the build. 
> Apart from that directory it should trigger the build.
> Is there any way we can achieve this in jenkins pipeline?
>
>
> Regards,
> Yogesh Bidari

-- 
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/4d0c3e1b-63fe-4e33-9a34-a6c6adaa1090n%40googlegroups.com.


Re: one downstream with multiple upstreams(all upstreams should be success)

2020-09-01 Thread Gianluca
Hi,
why not triggering Job D directly from job A ? In this way, if you put that 
in a stage after job B and job C is triggered ... it will only be triggered 
if both succedded:

stage("Run B and C") {
  steps {
parallel(
  "job B": { buildJob ... },
  "job C:" { build Job ... },
}

stage("Run D") {
  steps {
   // this will run only if both Job B and C succeed
buildJob
  }
}

Cheers,
Gianluca.

Il giorno martedì 1 settembre 2020 alle 19:52:49 UTC+1 chenna keshav ha 
scritto:

> Hi,
>
> i have stuck with a small issue... i have a job A which triggers job B and 
> job C. for job B and job C downstream job is job D i need this job D is 
> to be triggered when job B and job C both are success. i have tried with 
> "Build after other projects are build" with "trigger only if build is 
> stable" option. its not working for me... the job is getting triggered even 
> one of jobs is success. can some one please help me on this..
>
> Thanks,
> Keshav.
>

-- 
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/d4839902-97c8-4eb5-baa2-a080a400cfdbn%40googlegroups.com.


Re: Triggering builds from changes in sub-directories using Github Branch Source

2020-08-17 Thread Gianluca


Il giorno lunedì 17 agosto 2020 alle 16:54:26 UTC+1 j...@multani.info ha 
scritto:

> On Tuesday, 11 August 2020 at 15:55:17 UTC+2 Gianluca wrote:
>
>> Hi,
>> yes ... we do.
>>
>> We have various Jenkinsfile in sub-directories and different pipelines.
>>
>> This is how we did it:
>> - we have one Multibranch project for each Jenkinsfile and in the 
>> configuration we specify which Jenkinsfile is used for the jobs
>> - we have a custom check that we use on the "when" block to avoid that a 
>> pipeline is been built when a push only affects other directories
>>
>> // There is a bug in the changeset Jenkins command: 
>> https://issues.jenkins-ci.org/browse/JENKINS-44849
>> // ---
>> // It returns true if the list of changed files in the PR matches the grep 
>> pattern passed
>> // NOTE: it will always returns true in case the build is running on a 
>> branch and not on a PR
>> // because we always want to run a full pipelines on master, release and 
>> feature branches
>> def areFilesChanged(grepPattern) {
>> if (!env.CHANGE_TARGET) return true
>> sh(
>> // NOTE: the triple-dot are necessary to get the same diff result 
>> shown by GitHub PRs
>> script: "git diff origin/${env.CHANGE_TARGET}...HEAD --name-only | 
>> grep '${grepPattern}'",
>> returnStatus: true
>> ) == 0
>> }
>>
>>
>> and that's it.
>>
>
> I see, is this function called within the Jenkinsfile itself, right?
>
Yes.
 

> Is your build starting to run, then you are calling that function and the 
> build is interrupted prematurely if the files modified doesn't match your 
> pattern? 
>
Yes. We do in two different ways depending on which one fits better:
1) Using the "when" option of the stage:
stage("something") {
  when { expression { areFilesChanged("src/python3") } }
...

2) Using an if condition inside a script block
script {
   if ( areFilesChanged("src/rails") ) {
 ... steps
   }

} 



>
> On Tuesday, 11 August 2020 14:46:40 UTC+1, Jonathan Ballet wrote:
>>>
>>>
>>> Hello,
>>>
>>> In one of our Git repository, we have a directory hierarchy similar to 
>>> this:
>>>
>>> dev/
>>> Jenkinsfile
>>> folder-1/Jenkinsfile
>>> folder-2/Jenkinsfile
>>>
>>> test/
>>> Jenkinsfile
>>> folder-3/Jenkinsfile
>>> folder-4/Jenkinsfile
>>>
>>> There are other files as well, in each sub-directories.
>>>
>>> I'm looking for a way to have 6 builds out of this repository:
>>>
>>> * 1 build runs `dev/Jenkinsfile` when any file changes in the `dev/` 
>>> directory and children
>>> * 1 build runs `dev/folder-1/Jenkinsfile` when any file changes in the 
>>> `dev/folder-1/` directory
>>> * 1 build runs `dev/folder-2/Jenkinsfile` when any file changes in the 
>>> `dev/folder-2/` directory
>>> * etc.
>>>
>>> Also, I'd like to have these builds scopped by branches, we are using the
>>> Multibranch Pipeline (+ GitHub Branches Source) build type for that.
>>>
>>> Is there a known solution that combines all the above? (sub-directories, 
>>> pipelines, webhooks triggered by Git(Hub) with branches support)
>>>
>>> Thanks!
>>>
>>

-- 
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/312bb201-5369-4814-8864-df95a0f05127n%40googlegroups.com.


Re: Newbie questions about the declarative syntax

2020-08-14 Thread Gianluca
Hi Anton,
take into account that the declarative syntax (and in general Jenkins 
pipelines) are just a DSL (
https://en.wikipedia.org/wiki/Domain-specific_language) heavily based on 
Groovy language (http://groovy-lang.org/index.html).
So, many (really many) things you can do ... it's just Groovy language, 
like the one you asked.
In fact, triple quote is documented at 
http://groovy-lang.org/syntax.html#_triple_single_quoted_string
And also many "command" like "bat" you mentioned in the email are just 
Groovy function and follow the Groovy rules about parameters and how you 
can call them.
In the case of "bat" is you just pass one parameter is used as script, as 
you pass more than one you need to specify who is what:
"bat script: "whatever", returnStout: true"

I hope it helps to get you started on learning it.

Cheers,
Gianluca.


Il giorno venerdì 14 agosto 2020 alle 17:12:40 UTC+1 Anton Shepelev ha 
scritto:

> Hello, all
>
> From some examples in the internet I have found that a
> mulitline Windows batch script in Jenkins may be called with
> this step:
>
> bat """
> chcp 1251
> c:\path\to\program.exe
> """
>
> Where is this syntax documented with regard to:
>
> 1. the backslash escapes, and
> 2. the triple quoataion marks?
>
> Accoring to the steps reference, the `bat' step can take
> many parateters, the first being `script'. How I invoke the
> `bat' step with several parameters, e.g.: `script' and
> `returnStdout'?
>
> Where is the general specification of the declarative
> syntax? I am somewhat confused because the documentation
> starts from specific examples.
>
>

-- 
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/406d5273-6d8d-4e50-aae1-5c0099226c1cn%40googlegroups.com.


Re: Pipeline design question

2020-08-11 Thread Gianluca
Hi,
from functional point of view there is no different ... but there are from 
reporting point of view ... and that's a matter of taste :-)

1. In BlueOcean view, each "sh" invocation will be displayed separately 
from the other steps and "sh" takes as parameter a name that BlueOcean will 
use to report the steps.

2. It will appears as a single step in BlueOcean and you will have to go 
into the details and look at the log output to see the result of each 
"inner" sh command

3. Assuming you wanted to say in its own "stage" and not step (because 
that's point 1), then each "sh" command will have its own "circle" on 
BlueOcean pipeline view that becomes green or red based on the outcome

4. It's exactly as point 2, but probably much easier to maintain

Cheers,
Gianluca.
 

On Tuesday, 11 August 2020 15:33:33 UTC+1, Sébastien Hinderer wrote:
>
> Dear all, 
>
> When a pipeline needs to run a sequence of several shell commands, I see 
> several ways of doing that. 
>
> 1. Several "sh" invocations. 
>
> 2. One "sh" invocation that contains all the commands. 
>
> 3. Having each "sh" invocation in its own step. 
>
> 4. Putting all the commands in a script and invoking that script through 
> the sh step. 
>
> Would someone be able to explain the pros and cons of these different 
> approaches and to advice when to use which? Or is there perhaps a 
> reference I should read? 
>
> Thanks, 
>
> Sébastien. 
>

-- 
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/c88c6e50-b84f-4acd-b627-c81612da5658o%40googlegroups.com.


Re: Triggering builds from changes in sub-directories using Github Branch Source

2020-08-11 Thread Gianluca
Hi,
yes ... we do.

We have various Jenkinsfile in sub-directories and different pipelines.

This is how we did it:
- we have one Multibranch project for each Jenkinsfile and in the 
configuration we specify which Jenkinsfile is used for the jobs
- we have a custom check that we use on the "when" block to avoid that a 
pipeline is been built when a push only affects other directories

// There is a bug in the changeset Jenkins command: 
https://issues.jenkins-ci.org/browse/JENKINS-44849
// ---
// It returns true if the list of changed files in the PR matches the grep 
pattern passed
// NOTE: it will always returns true in case the build is running on a branch 
and not on a PR
// because we always want to run a full pipelines on master, release and 
feature branches
def areFilesChanged(grepPattern) {
if (!env.CHANGE_TARGET) return true
sh(
// NOTE: the triple-dot are necessary to get the same diff result shown 
by GitHub PRs
script: "git diff origin/${env.CHANGE_TARGET}...HEAD --name-only | grep 
'${grepPattern}'",
returnStatus: true
) == 0
}


and that's it.

Cheers,
Gianluca.


On Tuesday, 11 August 2020 14:46:40 UTC+1, Jonathan Ballet wrote:
>
>
> Hello,
>
> In one of our Git repository, we have a directory hierarchy similar to 
> this:
>
> dev/
> Jenkinsfile
> folder-1/Jenkinsfile
> folder-2/Jenkinsfile
>
> test/
> Jenkinsfile
> folder-3/Jenkinsfile
> folder-4/Jenkinsfile
>
> There are other files as well, in each sub-directories.
>
> I'm looking for a way to have 6 builds out of this repository:
>
> * 1 build runs `dev/Jenkinsfile` when any file changes in the `dev/` 
> directory and children
> * 1 build runs `dev/folder-1/Jenkinsfile` when any file changes in the 
> `dev/folder-1/` directory
> * 1 build runs `dev/folder-2/Jenkinsfile` when any file changes in the 
> `dev/folder-2/` directory
> * etc.
>
> Also, I'd like to have these builds scopped by branches, we are using the
> Multibranch Pipeline (+ GitHub Branches Source) build type for that.
>
> Is there a known solution that combines all the above? (sub-directories, 
> pipelines, webhooks triggered by Git(Hub) with branches support)
>
> Thanks!
>

-- 
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/ed2852e4-d205-4719-a769-9224800a163bo%40googlegroups.com.


Re: cannot get build causes

2020-07-30 Thread Gianluca
Hi,
that is a confusing error in my point of view that you will learn to 
interpret :-) 

The pipeline you wrote is a declarative one and the usage of "def ... " is 
something you can do only in scripted pipelines ... hence, what the error 
really means is: "You forgot to open a script block".

The fix is just to wrap inside a "script" block that allow to execute 
scripted portion inside a declarative pipeline:

pipeline {
agent any
stages {
stage('example') {
steps {
script {
  def causes = currentBuild.getBuildCauses()
  echo "Causes are ${causes}"
}
}
}
}
}

On Wednesday, 29 July 2020 22:04:44 UTC+1, Tom Brownridge wrote:
>
> Hello,
>
> I am new and am fundamentally misunderstanding pipeline syntax and cannot 
> relate the examples in the documentation. What am I missing?
>
> Looking at the example here: 
> https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/get-build-cause/getBuildCause.groovy,
>  
> I see a code snippet like this:
>
> def causes = currentBuild.getBuildCauses()
>
> But when I try to write a pipeline script to use it:
>
> pipeline {
> agent any
> stages {
> stage('example') {
> steps {
> def causes = currentBuild.getBuildCauses()
> echo "Causes are ${causes}"
> }
> }
> }
> }
>
> I get the following error:
>
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> WorkflowScript: 6: Expected a step @ line 6, column 17.
>def causes = currentBuild.getBuildCauses()
>^
>
> 1 error
>
>   at 
> org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
>   at 
> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
>   at 
> org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
>   at 
> org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
>   at 
> org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
>   at 
> groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
>   at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
>   at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
>   at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
>   at 
> org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
>   at 
> org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
>   at 
> org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
>   at 
> org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
>   at 
> org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:337)
>   at hudson.model.ResourceController.execute(ResourceController.java:97)
>   at hudson.model.Executor.run(Executor.java:428)
> Finished: FAILURE
>
> Thanks in advance.
>
> Sincerely,
> Tom
>
>
>
>
>
>
>

-- 
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/21658d43-59e3-4619-96cc-f4d54ec86299o%40googlegroups.com.


Re: Jenkins and HTTPS

2020-07-24 Thread Gianluca
Trying to guess:

" java.net.SocketException: Permission denied" 

this smells of Java not running with enough privileges to open ports below 
1024
Usually on Linux systems only root can open such ports.


On Friday, 24 July 2020 16:04:36 UTC+1, gaiseric.vandal wrote:
>
> I am setting up jenkins on an CentOS 8 machine.  Currently have one 
> running under Ubuntu 16.
>
>
> On the new machine, I am unable to get HTTPS working, even tho the config 
> seems the same as the other machine.
>
>
> My partial config file is 
>
>
>
> # cat /etc/sysconfig/jenkins
> #
> JENKINS_HOME="/var/lib/jenkins"
> JENKINS_JAVA_CMD=""
> JENKINS_USER="jenkins"
> #JENKINS_INSTALL_SKIP_CHOWN="false"
> JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true"
> JENKINS_PORT="8080"
> JENKINS_LISTEN_ADDRESS=""
> JENKINS_HTTPS_PORT="443"
> JENKINS_HTTPS_KEYSTORE="/etc/jenkins/jenkins.jks"
> JENKINS_HTTPS_KEYSTORE_PASSWORD="xxx"
> JENKINS_HTTPS_LISTEN_ADDRESS="0.0.0.0"
> JENKINS_HTTP2_PORT=""
> JENKINS_HTTP2_LISTEN_ADDRESS=""
> JENKINS_DEBUG_LEVEL="5"
> JENKINS_ENABLE_ACCESS_LOG="no"
> JENKINS_HANDLER_MAX="100"
>
> JENKINS_HANDLER_IDLE="20"
> JENKINS_EXTRA_LIB_FOLDER=""
> JENKINS_ARGS=""
> #
>
>
>
>
> I am quite certain I have the key store correct
>
>
> I set up with 
>
> keytool -genkey -alias servername.mydomain.com   -keyalg RSA 
> -keystore /etc/jenkins/jenkins.jks -keysize 2048
>
> Then generated a CSR, had it signed by our internal CA.
>
> Also imported the certificates for the CA's.
>
>
>
>
>
> I have the following errors
>
>
> $ cat /var/log/jenkins/jenkins.log
>
> Running from: /usr/lib/jenkins/jenkins.war
>
> Exception in thread "Jenkins initialization thread" 
> java.lang.NoClassDefFoundError: hudson/util/HudsonFailedToLoad
>
> at hudson.WebAppMain$3.run(WebAppMain.java:276)
>
> Caused by: java.lang.ClassNotFoundException: 
> hudson.util.HudsonFailedToLoad
>
> at java.net.URLClassLoader.findClass(Unknown Source)
>
>at java.lang.ClassLoader.loadClass(Unknown Source)
>
> at java.lang.ClassLoader.loadClass(Unknown Source)
>
> at 
> org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:543)
>
> at java.lang.ClassLoader.loadClass(Unknown Source)
>
> ... 1 more
>
> java.io.IOException: Failed to start Jetty
>
> at winstone.Launcher.(Launcher.java:184)
>
> at winstone.Launcher.main(Launcher.java:355)
>
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>
> at java.lang.reflect.Method.invoke(Unknown Source)
>
> at Main._main(Main.java:375)
>
> at Main.main(Main.java:151)
>
> Caused by: java.net.SocketException: Permission denied
>
> at sun.nio.ch.Net.bind0(Native Method)
>
> at sun.nio.ch.Net.bind(Unknown Source)
>
> at sun.nio.ch.Net.bind(Unknown Source)
>
> at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown 
> Source)
>
> at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
>
> at 
> org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
>
> at 
> org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
>
> at 
> org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
>
> at 
> org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:231)
>
> at 
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
>
> at 
> org.eclipse.jetty.server.Server.doStart(Server.java:385)
>
> at 
> org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:72)
>
> at winstone.Launcher.(Launcher.java:182)
>
> ... 7 more
>
> $
>
>
>
> I also tried extracting the key and cert  and tried the following
>
>  /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized 
> -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar 
> /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log 
> --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --httpsPort=443   
> --httpsListenAddress=0.0.0.0 --debug=5 --handlerCountMax=100 
> --

Re: Calling writeFile for every entry of a map requires somewhat ugly code

2020-07-18 Thread Gianluca
I use a different approach ... but it may not fits your use case.
In any case, usually when I have to perform operation on each element of a 
Map, I end up on transform the Map on steps that I can feed to parallel

steps {
  stepsMap = [:]

  stepsMap = dataMap.collectEntries{[
"Name of step to perfom (that will appear on BlueOcean": {
   // pipeline code, I usually use script block here to be able to do 
stuff not available in declarative
}
  ]}

  parallel stepsMap

}


By default collectEntries put the value into a variable called $it ... but 
the there is a syntax that allow to use key and value variables and use 
them inside.




On Saturday, 18 July 2020 19:28:32 UTC+1, David Karr wrote:
>
> I'm posting this mostly so people can find it.  Perhaps it's already 
> well-known, and perhaps I'm missing some simple thing that makes this 
> easier to do, but I think not.
>
> In my Jenkinsfile, I need to iterate over a map created with Groovy, 
> calling "writeFile" with the key as the file name, and the value as the 
> contents.  If you haven't had to do this, you might assume this is simple. 
> If you have, you either discovered what I did, or you gave up.
>
> What I tried to write first was this:
> dataMap.each {
> writeFile(file: "target/generated." + key, text: value)
> }
>
> This gets serialization errors.  I then discovered that calling pipeline 
> steps within closures would not work, so I changed it to a plainer 
> iteration:
>
> for(Map.Entry entry : dataMap) {
> writeFile(file: "target/generated." + entry.getKey(), text: entry.
> getValue())
> }
>
> This also does not work. It appears that you simply can't call a pipeline 
> step with a map anywhere in scope.
>
> What DOES work is something like the following:
> def keyValueList = []
> for (Map.Entry entry : dataMap) {
> keyValueList.add(entry.getKey())
> keyValueList.add(entry.getValue())
> }
> dataMap = null
> for (int ctr = 0; ctr < keyValueList.size(); ctr += 2) {
> writeFile(file: "target/generated." + keyValueList.get(ctr), text: 
> keyValueList.get(ctr + 1))
> }
> keyValueList = null
>
> Suggestions would be useful, or perhaps other people will just do the same 
> thing I've done.
>

-- 
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/569ba94d-b5e6-4956-ac7d-cd2e3bf4b692o%40googlegroups.com.


Re: Reasons for job termination

2020-07-03 Thread Gianluca
Hi,
what you describe seems something we experienced.
The issue in our case was that the Jenkins agents were VMs running on an 
overloaded host with network issues.
A combination of network errors, agents not responding and IP exhaustion 
made Jenkins terminating the jobs with SIGTERM when it was uncapable to 
restore connection with the agent.
It was hard to find because the host running the VMs was overloaded when 
the agents were doing something so it was something like:
agent was ok -> agent started to build a job -> job was spawning other VMs 
for testing -> host got overloaded -> agent could run properly -> Jenkins 
lost connection with agent -> job got terminated -> host not anymore in 
overload -> agent ok again -> jenkins restored connection with agent.


On Friday, 3 July 2020 08:19:22 UTC+1, fabian wrote:
>
> Hi 
>
> We've been using Jenkins for years now. Recently a problem has 
> come up that I can't explain. Jobs started to get terminated with 
> no apparent reason. With a signal handler I found that it's 
> apparently the Jenkins user that is sending the SIGTERM to 
> the running process. 
>
> What are reasons for Jenkins to stop a job? 
>
> There is no second build being started and it's throttled anyway. 
> The build timeout plugin is installed but this is a pipeline job 
> where it doesn't work. And I don't use the timeout options in 
> the pipeline. 
> I don't see anything in the jenkins log at that time. 
>
> How can I find out why the job is killed? 
>
> Thanks 
>
> bye  Fabi 
>
>

-- 
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/813456d7-1d87-4a40-b954-ddfd6c431c86o%40googlegroups.com.


Re: Download the git repo and use it for the downstream job

2020-07-01 Thread Gianluca
Hi,
it's hard to help with so little context.
For big what you mean? what is the actual size of the repository?
Git .. exactly where is the remote? GitHub, Gitlab, other?
The error is intermittent or constant? (i.e. could a simple retry do the 
trick?)


On Wednesday, 1 July 2020 20:03:12 UTC+1, sravan wrote:
>
> Hi All,
>
> My git repo is really big and I am running job parallel on two different 
> machine.Sometimes I see an issue with downloading from git . I get this 
> error "failed on download from git" Error.
>
> ERROR: Timeout after 10 minutes
> ERROR: Error cloning remote repo 'origin'
> returned status code 128:
> stdout: 
> stderr: remote: Enumerating objects: 522, done.
> remote: Counting objects:   0% (1/522)
> remote: Counting objects:   1% (6/522)
>
>
> Could anyone help me with this please
>

-- 
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/113403d9-abd0-4d73-9ec0-6b684e893315o%40googlegroups.com.


Re: jenkins agent definition loaded from a jenkins library

2020-06-15 Thread Gianluca
Hi,
I'm not entirely sure what are you looking for but I want to tell you that 
you can use variables as image name, or at least you can do for agent 
labels:

agent{ label "${builder.label" }

We use the above in our pipelines to have different agents depending on the 
branch and PR number and other environment factors.

Cheers,
Gianluca.


On Monday, 15 June 2020 13:20:05 UTC+1, Marco Sacchetto wrote:
>
> Hi,
>
> I'm currently using a Jenkins declarative pipeline (note: if my issue 
> would be solved with a scripted pipeline, I can switch).
> The builds run inside an ephemeral docker agent spinned up by the pipeline 
> using a syntax similar to
>
> agent{ docker{ image "my-image"}}}
>
> The issue with that is that I'm going to have a big number of pipelines 
> defined as Jenkinsfiles which are all kind of similar
> to each other, and all of them will be running using the same docker agent.
> As such, I'd love to be able to parameterise the image name by defining it 
> as a variable or as a function inside a jenkins
> library, so that if the image needs to be change I don't have to commit 
> back to all of the existing Jenkinsfile.
>
> I saw it's possible to define the whole declarative pipeline inside a 
> function, but there seems to be no option to set instead 
> just some String variable to be used when setting up the agent, and no 
> possibility to define anything to run outside of the
> normal pipeline steps - is that correct?
>

-- 
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/95d98d96-f65f-4519-8c16-751ab6e746e6o%40googlegroups.com.


Re: how to use git commands inside a Multi Branch Project?

2020-05-29 Thread Gianluca
Hi Christian,
I'm doing it in a pipeline that runs various git commands to check out, 
push and open PRs automatically for some DevOps.

This is how I did:

I've created a bash script git_password_helper.sh with the following 
content:

#!/bin/sh

exec echo "$GITHUB_PSW"



The in the pipeline, I set the environment to use the GitHub credentials I 
need:

environment {
GITHUB = credentials('user_github_token')
}

I use the personal access token instead of user password because it works 
and it's more secure than storing password on Jenkins credentials.

Then, I have a bash script containing all the git commands I have to run 
and the trick is to set GIT_ASKPASS to the bash script above:

export GIT_ASKPASS=./scripts/git_password_helper.sh

git ... 
git ...
git ...


How does it works?

The pipeline injects into environment variable GITHUB_USR/PWD the user and 
access token and they are available to the bash script running the git 
command, then the GIT_ASKPASS instructs git to call the 
git_password_helper.sh when it needs the user's password instead of 
prompting ... and the git_password_helper.sh echo the GITHUB_PWD containing 
the access token stored into Jenkins credentials.

That works for me.

Cheers,
Gianluca.



On Friday, 29 May 2020 10:50:29 UTC+1, Christian Baumann wrote:
>
> Hi all,
>
> I know this topic is rather old, but I´m facing the very same issue and 
> was not able to find a proper solution.
> Has anything changed since this question has been raised and someone could 
> provide an answer?
>
> Many thanks,
> Christian
>
> Am Mittwoch, 30. November 2016 12:20:22 UTC+1 schrieb Torsten Reinhard:
>>
>> Hi all,
>>
>> I have a Multi Branch Project, using a *.git Repository. All branches are 
>> detected and the checkout is working. 
>> In my JenkinsFile I need to execute some "git" commands, like:
>>
>> ...
>> sh "git tag -d FOR_INTEGRATION_TESTING" // removes 
>> the tag in local env.
>> sh "git push origin :refs/tags/FOR_INTEGRATION_TESTING"// 
>> removes the tag in remote env.
>> sh "git tag -a FOR_INTEGRATION_TESTING"// adds 
>> the tag to different commit
>> sh "git push origin FOR_INTEGRATION_TESTING"// pushes 
>> the change to the remote
>> ...
>>
>> How can I apply the credentials here ? 
>> When trying 
>>
>> withCredentials [$class: 'UsernamePasswordMultiBinding', credentialsId: 
>> git_creds, usernameVariable: 'G_USER', passwordVariable: 'G_PASS'] {
>>   ...
>> }
>>
>>
>> I see this exception:
>>
>> org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: 
>> Credentials 'a378e16a-3d20-4465-aef1-b2bd233f15b6' is of type 'SSH Username 
>> with private key' 
>> where 
>> 'com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials'
>>  was expected
>>
>>
>> Is there another class instead of "UsernamePasswordMultiBinding" I have 
>> to use? 
>>
>> Thanx for pointing me in the right direction, 
>>
>> Torsten
>>
>>
>>

-- 
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/ecd2911c-235c-4ddb-80d8-b2adb1a21d46%40googlegroups.com.


Re: How to cleanup workspace built from docker

2020-05-12 Thread Gianluca
The best solution is not run any command as root inside docker.
Use the environment variables UID and GID and run the docker with a user 
corresponding to the UID and GIU; something like "--user $UID:$GID" instead 
of root



On Tuesday, 12 May 2020 08:51:43 UTC+1, Den wrote:
>
> Hi,
>
> I'm building artifacts in docker image and if I'm aborting a build, the 
> deleteDir function fails to delete artifacts since
> they were created with root user in docker and the function is called by 
> jenkins user outside of docker. Is there any workaround?
>
> pipeline {
> agent {label 'docker'}
> stages {
> stage('Build') {
> agent {
> docker {
> image 'adoptopenjdk/openjdk8' args '-u root -v 
> $HOME/.m2:/root/.m2' reuseNode true label 'docker'
> }
> }
> stages {
> stage ('Package') {
> sh "./mvnw package"
> }
> }
> post {
> always {deleteDir()}
> } 
> }
> }
> post {
> always {deleteDir()}
> }
> }
>

-- 
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/04843dc4-4e57-4b65-9aa0-11f78f62efcd%40googlegroups.com.


Re: Hi friend i have 2 lockable resource while executing same job 2 times i want 2nd job will move 2nd lcokable resource how can i do it

2020-04-30 Thread Gianluca

It's not really clear what you want ... but nevertheless I think you have 
got the solution.
You have an "if" ... you just need to figure it out what is the condition 
that makes you go to the else branch.

So, why one job should lock "Resource 1" and another should "Resource 2"?


On Thursday, 30 April 2020 09:37:41 UTC+1, Satya Muralidhar Peddireddi 
wrote:
>
> pipeline {
> agent any
> stages {
> stage('sample_1') {
> steps { 
> script {
> if(true) {
> lock(label: 'Resource1') {
> sh label: '', script: 'echo $JAVA_HOME'
> sleep time: 1, unit: 'MINUTES'
> }   
> } 
> else{
> lock(label: 'Resource2') { 
> sh label: '', script: 'echo $JAVA_HOME'
> sleep time: 1, unit: 'MINUTES'
> }
> }
> }
> }
> }
> }
> }
>
>
>

-- 
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/56d4aaa9-5435-4a18-ac5a-a4659222538e%40googlegroups.com.


Re: Jenkinsfile integration with Azure AKS

2020-04-01 Thread Gianluca
It's difficult to answer your question because it's too much broad and 
generic.

What you asked is: "Can we basically integrate on prem Jenkins with Azure 
aks " ... and even I've never used Azure AKS, I'm 100% sure that the answer 
is Yes ... but I'm also 100% sure that's not what you are asking ;-) :-P

I had experience with deploying stuff from Jenkins to vSphere/vCenter, AWS, 
wordpress engine, CDNs, NAS, GitHub, Artifactory (and maybe some other I 
forgot).

So, what exactly you are looking for?


On Thursday, 2 April 2020 07:49:51 UTC+1, Prakasun wrote:
>
> Any suggestions will be highly appreciated
>
> On Thu, 2 Apr, 2020, 12:06 am Prakasun,  > wrote:
>
>> Team,
>>
>> We have to write a jenkinsfile in which we want to integrate Continous 
>> deployment part with Azure AKS. Our on prem data center Jenkins will 
>> automatically deploy app into Azure AKS. No documents available for this 
>> kind requirements. All the documents suggest Jenkins bootstrap through 
>> Azure agent vm and Azure market place. Can we basically integrate on prem 
>> Jenkins with Azure aks 
>>
>> Any suggestions would be really great.
>>
>> Warm Regards,
>>
>> -- 
>> 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/ee6c3cbf-da2d-47b3-b823-f85f1c188db3%40googlegroups.com
>> .
>>
>

-- 
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/871cb530-ce7a-44a3-b0c1-1c4cd8403933%40googlegroups.com.


Re: Make vSphere plugin work

2020-04-01 Thread Gianluca
We had these issue in the past ... and this is what we discovered:
1) VSphereNotFoundException is raised also in the case the user don't have 
permission to see it.
So, considering you are 100% sure the name is correct, I can tell you that 
it's a permission error.

2) I know it may seems strange ... I'm still scratching my head ... but 
even if a user is an administrator on vCenter, it may not have enough 
permissions on an ESXi datastore.
How this happens ... we never figure it out ... but the guy who is managing 
vCenter in our case, he was setting explicit permission on the single 
entity directly on the EXSi host and vCenter to workaround this issue.
I don't have more details than that about this permission issues, sorry

Cheers,
Gianluca.


On Wednesday, 1 April 2020 20:40:02 UTC+1, Christoph Fetzer wrote:
>
> Hi Gianluca,
>
> OK, the log was a good idea, thank you very much!
> There I found:
>
> Started provisioning VC9BuildSlave97yt3vpya79krvglcpcgevei4 from vSphereCloud 
> with 1 executors. Remaining excess workload: 0
>
> Apr 01, 2020 5:13:01 PM WARNING 
> org.jenkinsci.plugins.vSphereCloud$VSpherePlannedNode$1 call
>
> Failed to provision new slave VC9BuildSlave97yt3vpya79krvglcpcgevei4
> org.jenkinsci.plugins.vsphere.tools.VSphereNotFoundException: vSphere Error: 
> Datastore "XXX_RAID5_Datastore" not found
> at 
> org.jenkinsci.plugins.vsphere.tools.VSphere.createRelocateSpec(VSphere.java:336)
> at 
> org.jenkinsci.plugins.vsphere.tools.VSphere.cloneOrDeployVm(VSphere.java:235)
> at 
> org.jenkinsci.plugins.vSphereCloudSlaveTemplate.provision(vSphereCloudSlaveTemplate.java:428)
> at 
> org.jenkinsci.plugins.vSphereCloudSlaveTemplate.provision(vSphereCloudSlaveTemplate.java:403)
> at 
> org.jenkinsci.plugins.vSphereCloud$VSpherePlannedNode.provisionNewNode(vSphereCloud.java:534)
> at 
> org.jenkinsci.plugins.vSphereCloud$VSpherePlannedNode.access$100(vSphereCloud.java:496)
> at 
> org.jenkinsci.plugins.vSphereCloud$VSpherePlannedNode$1.call(vSphereCloud.java:510)
> at 
> org.jenkinsci.plugins.vSphereCloud$VSpherePlannedNode$1.call(vSphereCloud.java:506)
> at 
> jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
> at 
> jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71)
> at java.util.concurrent.FutureTask.run(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> Unfortunately this exactly matches the name of the datastore as displayed 
> in vSphere (copy'n'pasted - replace the triple X with the actual hostname).
> [image: Capture.PNG]
>
>
>
>
>
>
>
>
>
>
> Sorry for the german UI. Did I get something wrong? Isn't this the proper 
> ID for the datastore?
> The user is administrator on the whole server (I know but that's the next 
> step).
>
> BR,
> Christoph
>
>
> Am Mittwoch, 1. April 2020 17:38:11 UTC+2 schrieb Gianluca:
>>
>> Hi,
>> we use vSphere cloud plugin and some hints to help you debug:
>> 1) go to the Jenkins log and check any error there
>> Some errors we had in the past:
>> - typo in the node label and the clone never started
>> - clone started but it was failing due to permission errors in vSphere 
>> (the user is not able to do the action, test connection only check that you 
>> can connect ... not all permission needed)
>>
>> 2) go to the vCenter and check that the VM is actually created; we had 
>> issues with the VM not being powered on or wrong networking into the 
>> template
>>
>> 3) go to the "Nodes" on Jenkins and check that the node appears there
>>
>> 4) go to the Node page and check any logs for any error
>>
>>
>>
>> On Wednesday, 1 April 2020 16:13:45 UTC+1, Christoph Fetzer wrote:
>>>
>>> Hi,
>>>
>>> I have access to an Esxi-Server used by a vSphere instance. I set up a 
>>> vsphere cloud in my Jenkins installation properly ("Test connection" works).
>>> I set up a template VM (Windows 10) with a Snapshot, Autologon and 
>>> Autostart according to 
>>> https://github.com/jenkinsci/vsphere-cloud-plugin/blob/master/docs/vm-configuration.md
>>> I configured a startup template in the vSphere cloud according to: 
>>> https://github.com/jenkinsci/vsphere-cloud-plugin/blob/master/docs/jenkins-configuration.md
>>> I'd like to use the approch "

Re: Jenkins HTML publishing on build level without copies

2020-04-01 Thread Gianluca
Hi,
I think you misunderstood the meaning of
reportDir: "/${reportDir}",

The publishHTML publishes the directory ... not the file. The reportFiles 
is the "index" that is loaded as beginning but it's the reportDir with 
whole is content that is published by the plugin.

So, you can't have a reportDir that's shared across builds or everything 
will be published for all builds getting duplicates.

I'm not sure why do you need the build number in the index file, Jenkins 
publishHTML plugin already put the generated files into separated builds 
directory as you already found out by looking at the reportDirs.

So, I would suggest to rethink your strategy of building reports and avoid 
file names with build number into it.

Cheers,
Gianluca.


On Wednesday, 1 April 2020 20:20:56 UTC+1, Filip Kosik wrote:
>
> Hi Gianluca,
>
> thank you for your answer. Here is an example of my problem:
>
> When I run pipeline code:
> def fileName = "index_${reportBuildNo}.html";
> … // HTML is generated here
> publishHTML (target: [
>   allowMissing: false,
>   alwaysLinkToLastBuild: false,
>   keepAll: true,
>   reportDir: "/${reportDir}",
>   reportFiles: fileName,
>   reportName: "Results"
> ])
> my build directories after 3 builds contains the following:
> build/1/htmlreports
>  - index_1.html
> build/2/htmlreports
>  - index_1.html
>  - index_2.html
> build/3/htmlreports
>  - index_1.html
>  - index_2.html
>  - index_3.html
>
> Maybe the problem is in my generic report filenames (including build 
> number). 
> My old and new HTML files are generated into one directory for all builds. 
> When HTML files are generated I pass only filenames of the current build to 
> htmlPublisher.
>
>
>
> On Wednesday, April 1, 2020 at 12:46:35 PM UTC-6, Gianluca wrote:
>>
>> Hi, I have this in my pipeline
>>
>> publishHTML target: [
>> allowMissing: true,
>> alwaysLinkToLastBuild: false,
>> keepAll: true,
>> reportDir: 'out/python3-cov',
>> reportFiles: '*/index.html',
>> reportName: 'Python 3 Coverage'
>> ]
>>
>>
>>
>> And I don't have old reports in builds. Each build has it own report 
>> built.
>>
>> So, or I don't understand what you are asking for, or you misunderstood 
>> the behaviour? 
>>
>> Can you details more what you mean with duplications?
>>
>>
>> On Wednesday, 1 April 2020 18:32:12 UTC+1, Filip Kosik wrote:
>>>
>>> Hi,
>>>
>>> I am trying to *publish HTML reports for each build*. I tried plugin 
>>> HtmlPublisher 
>>> (1.22) <https://plugins.jenkins.io/htmlpublisher/> but when it 
>>> publishes my reports on their build page (using keepAll=true), it 
>>> creates copies of reports from all previous builds in each build directory. 
>>> So, each Jenkins build includes many copies of old reports and they are 
>>> bigger and bigger. If I publish my reports on the project page (using 
>>> keepAll=false), old reports are preserved in their project directory 
>>> (in my file system) but only the last report is accessible from Jenkins. Is 
>>> there any way how to have reports *on their build pages without 
>>> creation of their duplicates*? Maybe, there is some parameter that I'm 
>>> still missing.
>>>
>>>
>>> My pipeline includes the following HtmlPublisher use:
>>>
>>>
>>> publishHTML (target: [
>>>   allowMissing: false,
>>>   alwaysLinkToLastBuild: false,
>>>   keepAll: true,
>>>   reportDir: "./htmlReports",
>>>   reportFiles: reportFileNames, //generic variable
>>>   reportName: "Results"
>>> ])
>>>  
>>>
>>> Thank you
>>>
>>

-- 
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/7e0ed674-b90c-473c-966c-e7a4d837caf0%40googlegroups.com.


Re: Jenkins HTML publishing on build level without copies

2020-04-01 Thread Gianluca
Hi, I have this in my pipeline

publishHTML target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'out/python3-cov',
reportFiles: '*/index.html',
reportName: 'Python 3 Coverage'
]



And I don't have old reports in builds. Each build has it own report built.

So, or I don't understand what you are asking for, or you misunderstood the 
behaviour? 

Can you details more what you mean with duplications?


On Wednesday, 1 April 2020 18:32:12 UTC+1, Filip Kosik wrote:
>
> Hi,
>
> I am trying to *publish HTML reports for each build*. I tried plugin 
> HtmlPublisher 
> (1.22)  but when it publishes 
> my reports on their build page (using keepAll=true), it creates copies of 
> reports from all previous builds in each build directory. So, each Jenkins 
> build includes many copies of old reports and they are bigger and bigger. 
> If I publish my reports on the project page (using keepAll=false), old 
> reports are preserved in their project directory (in my file system) but 
> only the last report is accessible from Jenkins. Is there any way how to 
> have reports *on their build pages without creation of their duplicates*? 
> Maybe, there is some parameter that I'm still missing.
>
>
> My pipeline includes the following HtmlPublisher use:
>
>
> publishHTML (target: [
>   allowMissing: false,
>   alwaysLinkToLastBuild: false,
>   keepAll: true,
>   reportDir: "./htmlReports",
>   reportFiles: reportFileNames, //generic variable
>   reportName: "Results"
> ])
>  
>
> Thank you
>

-- 
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/e18c985b-3e6d-43f2-a327-d8949c012da4%40googlegroups.com.


Re: Make vSphere plugin work

2020-04-01 Thread Gianluca
Hi,
we use vSphere cloud plugin and some hints to help you debug:
1) go to the Jenkins log and check any error there
Some errors we had in the past:
- typo in the node label and the clone never started
- clone started but it was failing due to permission errors in vSphere (the 
user is not able to do the action, test connection only check that you can 
connect ... not all permission needed)

2) go to the vCenter and check that the VM is actually created; we had 
issues with the VM not being powered on or wrong networking into the 
template

3) go to the "Nodes" on Jenkins and check that the node appears there

4) go to the Node page and check any logs for any error



On Wednesday, 1 April 2020 16:13:45 UTC+1, Christoph Fetzer wrote:
>
> Hi,
>
> I have access to an Esxi-Server used by a vSphere instance. I set up a 
> vsphere cloud in my Jenkins installation properly ("Test connection" works).
> I set up a template VM (Windows 10) with a Snapshot, Autologon and 
> Autostart according to 
> https://github.com/jenkinsci/vsphere-cloud-plugin/blob/master/docs/vm-configuration.md
> I configured a startup template in the vSphere cloud according to: 
> https://github.com/jenkinsci/vsphere-cloud-plugin/blob/master/docs/jenkins-configuration.md
> I'd like to use the approch "Static configuration" mentioned for startup 
> of the nodes.
> In the vSphere cloud I made the plugin use "VC9-build" als label for the 
> nodes.
> Then I changed a build job based on that Jenkinsfile (declarative):
>
> #!groovy
> pipeline {
> agent { 
> label 'VC9-build'
> }
> ...
> }
>
>
> My expectation is that after start of the job the vsphere plugin would 
> clone a VM in ESXI, start that up, connect it to jenkins and make the job 
> run there.
> Instead I only have a job in may waiting queue with the name "part of 
> ${jobname}" and I can't see anything on vSpere so I guess clone of the 
> machine didn't even start.
> Am I missing a link somewhere in to make the node creation start?
>
> BR,
> Christoph
>

-- 
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/491ea588-049c-4c2d-9645-cb3c042d6d7d%40googlegroups.com.


Re: Command line acccess to build actions in muti branch pipeline

2020-04-01 Thread Gianluca
Hi,
I'm not sure I'm following you ... or maybe we are using different ways to 
write our pipeline.
So, to be more explicit ... this is what we have in our pipeline:

pipeline {
triggers {
// runs every two hours
cron('H H/2 * * *')
}

That is a Multibranch project (to be precise we use GitHub, not sure if 
what I see maybe related to Git plugin itself) and what happens due to the 
"H" special case is that each branch will have a different starting hour 
and minutes that actually spread them over the time.
In that case you achieve the fact that there will never be two jobs 
starting at the same time.
Now, you can still have them overlap after they started.
To avoid that they run a certain stage at the same time we use locks:

steps {
// lock not usable in declarative pipeline due to JENKINS-43002
script { lock(label: resourceLabel, quantity: 1) {
With the above, what you achieve is that only and only one job at the time 
can run what's inside the script block.

We both cron and locks ... you spread your jobs across day hours and you 
are guaranteed that they run sequentially when the reach a part that can't 
be run by two jobs at the same time. And that works across branches.

On Wednesday, 1 April 2020 10:09:19 UTC+1, BCT Roel de Wildt wrote:
>
> Hi,
>
>  
>
> I have looked at it but it seems only possible if I change our Jenkinsfile 
> within each project stored in svn within the branches of it. And I can’t 
> see where to put the cron entry in the multi branch pipeline. I have only 
> the following options (… 12 hours, 1 day, 2 days, etc… ) in “Periodically 
> if not otherwise run” in the triggers section.
>
>  
>
> That means I can’t control the time it will be executed.
>
>  
>
> Alternative:
>
> I can execute a scheduled curl program which triggers the “trunk” 
> successfully, but the “branches/2019/trunk” gives a http 404 error.
>
>  
>
> Kind regards,
>
> Roel de Wildt
> Software Engineer
>
>  
>
> *Van:* jenkins...@googlegroups.com  [mailto:
> jenkins...@googlegroups.com ] *Namens *Gianluca
> *Verzonden:* woensdag 1 april 2020 09:17
> *Aan:* Jenkins Users >
> *Onderwerp:* Re: Command line acccess to build actions in muti branch 
> pipeline
>
>  
>
> Hi,
>
> we have a similar issue and we use a combination of trigger cron command 
> with "H" (if instead of * into cron syntax, you put "H" then Jenkins treats 
> it special)
>
> From documentation https://jenkins.io/doc/book/pipeline/syntax/
>
> "The H symbol can be thought of as a random value over a range, but it 
> actually is a hash of the job name, not a random function, so that the 
> value remains stable for any given project."
>
>  
>
> But also that's is not sufficient in cases the pipeline takes more than an 
> hour (as in our case), hence we add on top of this the usage of 
> LockableResources and we created a resource that we lock in the stages of 
> the pipeline we know we can't run at the same time because of constraints.
>
>  
>
> https://jenkins.io/doc/pipeline/steps/lockable-resources/
>
>  
>
> So, a combination of both ... does the tricks for us and I think it should 
> work as well for you too.
>
>  
>
> Cheers,
>
> Gianluca
>
>  
>
>
> On Wednesday, 1 April 2020 08:08:41 UTC+1, BCT Roel de Wildt wrote:
>
> Hello,
>
>  
>
> In previous versions of Jenkins LTS there was a jenkins-cli.jar which I 
> used to trigger a build job. Now with the latest (2.222.1) I can’t find how 
> to do the build jobs on a scheduled base. Where one is shedules at 19:00, 
> the other on 20:30, etc… They can’t run at same time due resources limits. 
> What is the best option to execute a single build job in a multi branch 
> pipeline?
>
>  
>
> Kind regards,
>
> Roel de Wildt
> Software Engineer
>
>  
>
> -- 
> 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/c96a2c92-9eb4-4e3e-9323-63c829418bc3%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/c96a2c92-9eb4-4e3e-9323-63c829418bc3%40googlegroups.com?utm_medium=email&utm_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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f880bc76-6669-401b-b1b4-b588e4c794df%40googlegroups.com.


Re: Command line acccess to build actions in muti branch pipeline

2020-04-01 Thread Gianluca
Hi,
we have a similar issue and we use a combination of trigger cron command 
with "H" (if instead of * into cron syntax, you put "H" then Jenkins treats 
it special)
>From documentation https://jenkins.io/doc/book/pipeline/syntax/
"The H symbol can be thought of as a random value over a range, but it 
actually is a hash of the job name, not a random function, so that the 
value remains stable for any given project."

But also that's is not sufficient in cases the pipeline takes more than an 
hour (as in our case), hence we add on top of this the usage of 
LockableResources and we created a resource that we lock in the stages of 
the pipeline we know we can't run at the same time because of constraints.

https://jenkins.io/doc/pipeline/steps/lockable-resources/

So, a combination of both ... does the tricks for us and I think it should 
work as well for you too.

Cheers,
Gianluca


On Wednesday, 1 April 2020 08:08:41 UTC+1, BCT Roel de Wildt wrote:
>
> Hello,
>
>  
>
> In previous versions of Jenkins LTS there was a jenkins-cli.jar which I 
> used to trigger a build job. Now with the latest (2.222.1) I can’t find how 
> to do the build jobs on a scheduled base. Where one is shedules at 19:00, 
> the other on 20:30, etc… They can’t run at same time due resources limits. 
> What is the best option to execute a single build job in a multi branch 
> pipeline?
>
>  
>
> Kind regards,
>
> Roel de Wildt
> Software Engineer
>
>  
>

-- 
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/c96a2c92-9eb4-4e3e-9323-63c829418bc3%40googlegroups.com.


Re: Conditional pipeline not working

2020-03-31 Thread Gianluca
Hi,
environment variables like "env.BRANCH_NAME" are not part of Jenkins core 
itself ... they are injected by additional plugins.
So, yes, you have to use "Multibranch" project type ... because it's that 
project that will inject that environment variables from what I know.

Look at the section "Additional Environment Variables" of the documentation 
https://jenkins.io/doc/book/pipeline/multibranch/



On Tuesday, 31 March 2020 15:42:51 UTC+1, kurusetra wrote:
>
> Hi,
>
> I'm using freestyle project type, it should be "Multibranch" project type?
>
> Yes, i'm sure that my project is configured to checkout "master" branch.
>
> > git show-ref --tags -d # timeout=10
>> Checking out Revision a57c28b1efb0749a9b89b72b540557e226b116bd 
>> (origin/master)
>>  > git config core.sparsecheckout # timeout=10
>>  > git checkout -f a57c28b1efb0749a9b89b72b540557e226b116bd # timeout=10
>> Commit message: "edit jenkinsfile"
>>
>>
> Thanks 
> Kurusetra 
>
> On Tue, Mar 31, 2020 at 9:37 PM Gianluca > 
> wrote:
>
>> Hi,
>> we are using
>>
>> if (env.BRANCH_NAME == 'master')
>>
>> in our pipeline and works great... so, if you tried with the line above 
>> ... this means that there is an error on how the pipeline is configured and 
>> run.
>> Are you using Multibranch project type?
>>
>> Are you sure your project is configured to checkout "master" branch?
>>
>>
>> On Tuesday, 31 March 2020 15:26:36 UTC+1, kurusetra wrote:
>>>
>>> Hi,
>>>
>>> Already changed from 'origin/master' to 'master' but still no luck, 
>>> pipeline still build the 'dev' image dan deploy to namespace 'dev', even i 
>>> commit in 'master' branch...
>>> Yes i'm using github.com for codes repository...
>>>
>>> Thanks
>>> Kurusetra
>>>
>>> On Tuesday, March 31, 2020 at 9:00:40 PM UTC+7, Gianluca wrote:
>>>>
>>>> We use similar conditionals ... and I think your error is in the branch 
>>>> name:
>>>>
>>>> env.BRANCH_NAME == 'origin/master'
>>>>
>>>> that should be instead:
>>>>
>>>> env.BRANCH_NAME == 'master'
>>>>
>>>> Because, if I'm guessing right, you are using Git ... and then the 
>>>> first part is the remote name, not the branch: / 
>>>> :-) 
>>>>
>>>> So, in your case the BRANCH_NAME is "master" and "origin" is the remote 
>>>> ... that you don't have to specify in Jenkins pipeline.
>>>>
>>>>
>>>> On Tuesday, 31 March 2020 14:44:06 UTC+1, kurusetra wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I just created jenkinsfile for deploy sample application to my k8s, 
>>>>> but the deployment always build "dev" image and deploy to dev namespace 
>>>>> in 
>>>>> k8s. i tried to commit in master branch but still build "dev" image dan 
>>>>> deploy to "dev" namespace in k8s.
>>>>>
>>>>> Please advice... whats wrong with my pipeline, fyi... i create the job 
>>>>> in jenkins with "freestyle".
>>>>>
>>>>> pipeline {
>>>>>> agent any
>>>>>> environment {
>>>>>> project_id = 'kurusetra'
>>>>>> app_name = 'nginx-hello'
>>>>>> }
>>>>>>
>>>>>> stages {
>>>>>>
>>>>>> stage('Clone Repository') {
>>>>>> steps {
>>>>>> checkout scm
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> stage('Build Docker Images') {
>>>>>> steps {
>>>>>> script {
>>>>>> if (env.BRANCH_NAME == 'origin/master') {
>>>>>> myapp = 
>>>>>> docker.build("${project_id}/${app_name}-prod:${env.BUILD_NUMBER}")
>>>>>> } else {
>>>>>> myapp = 
>>>>>> docker.build("${project_id}/${app_name}-dev:${env.BUILD_NUMBER}")
&g

Re: Conditional pipeline not working

2020-03-31 Thread Gianluca
Hi,
we are using

if (env.BRANCH_NAME == 'master')

in our pipeline and works great... so, if you tried with the line above ... 
this means that there is an error on how the pipeline is configured and run.
Are you using Multibranch project type?

Are you sure your project is configured to checkout "master" branch?


On Tuesday, 31 March 2020 15:26:36 UTC+1, kurusetra wrote:
>
> Hi,
>
> Already changed from 'origin/master' to 'master' but still no luck, 
> pipeline still build the 'dev' image dan deploy to namespace 'dev', even i 
> commit in 'master' branch...
> Yes i'm using github.com for codes repository...
>
> Thanks
> Kurusetra
>
> On Tuesday, March 31, 2020 at 9:00:40 PM UTC+7, Gianluca wrote:
>>
>> We use similar conditionals ... and I think your error is in the branch 
>> name:
>>
>> env.BRANCH_NAME == 'origin/master'
>>
>> that should be instead:
>>
>> env.BRANCH_NAME == 'master'
>>
>> Because, if I'm guessing right, you are using Git ... and then the first 
>> part is the remote name, not the branch: / :-) 
>>
>> So, in your case the BRANCH_NAME is "master" and "origin" is the remote 
>> ... that you don't have to specify in Jenkins pipeline.
>>
>>
>> On Tuesday, 31 March 2020 14:44:06 UTC+1, kurusetra wrote:
>>>
>>> Hi,
>>>
>>> I just created jenkinsfile for deploy sample application to my k8s, but 
>>> the deployment always build "dev" image and deploy to dev namespace in k8s. 
>>> i tried to commit in master branch but still build "dev" image dan deploy 
>>> to "dev" namespace in k8s.
>>>
>>> Please advice... whats wrong with my pipeline, fyi... i create the job 
>>> in jenkins with "freestyle".
>>>
>>> pipeline {
>>>> agent any
>>>> environment {
>>>> project_id = 'kurusetra'
>>>> app_name = 'nginx-hello'
>>>> }
>>>>
>>>> stages {
>>>>
>>>> stage('Clone Repository') {
>>>> steps {
>>>> checkout scm
>>>> }
>>>> }
>>>>
>>>> stage('Build Docker Images') {
>>>> steps {
>>>> script {
>>>> if (env.BRANCH_NAME == 'origin/master') {
>>>> myapp = 
>>>> docker.build("${project_id}/${app_name}-prod:${env.BUILD_NUMBER}")
>>>> } else {
>>>> myapp = 
>>>> docker.build("${project_id}/${app_name}-dev:${env.BUILD_NUMBER}")
>>>> }
>>>> }
>>>> }
>>>> }
>>>>
>>>> stage('Push Images') {
>>>> steps {
>>>> script {
>>>> docker.withRegistry('
>>>> https://docker.xxx.com/kurusetra', 'harbor') {
>>>> myapp.push("${env.BUILD_NUMBER}")
>>>> myapp.push("latest")
>>>> }
>>>> }
>>>> }
>>>> }
>>>>
>>>> stage('Deploy to K8s') {
>>>> steps {
>>>> script {
>>>> if (env.BRANCH_NAME == 'origin/master') {
>>>> sh "sed -i 
>>>> 's/${app_name}:latest/${app_name}-prod:${env.BUILD_NUMBER}/g' 
>>>> deployment.yaml"
>>>> sh 'kubectl apply -f ./deployment.yaml -n prod'
>>>> } else {
>>>> sh "sed -i 
>>>> 's/${app_name}:latest/${app_name}-dev:${env.BUILD_NUMBER}/g' 
>>>> deployment.yaml"
>>>> sh 'kubectl apply -f ./deployment.yaml -n dev'
>>>> }
>>>> }
>>>> }
>>>> }
>>>> }
>>>> }
>>>>
>>>
>>>
>>> Thanks
>>> Kurusetra 
>>>
>>

-- 
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/e06e3e0a-4d00-48df-a356-b024c3649a87%40googlegroups.com.


Re: Conditional pipeline not working

2020-03-31 Thread Gianluca
We use similar conditionals ... and I think your error is in the branch 
name:

env.BRANCH_NAME == 'origin/master'

that should be instead:

env.BRANCH_NAME == 'master'

Because, if I'm guessing right, you are using Git ... and then the first 
part is the remote name, not the branch: / :-) 

So, in your case the BRANCH_NAME is "master" and "origin" is the remote ... 
that you don't have to specify in Jenkins pipeline.


On Tuesday, 31 March 2020 14:44:06 UTC+1, kurusetra wrote:
>
> Hi,
>
> I just created jenkinsfile for deploy sample application to my k8s, but 
> the deployment always build "dev" image and deploy to dev namespace in k8s. 
> i tried to commit in master branch but still build "dev" image dan deploy 
> to "dev" namespace in k8s.
>
> Please advice... whats wrong with my pipeline, fyi... i create the job in 
> jenkins with "freestyle".
>
> pipeline {
>> agent any
>> environment {
>> project_id = 'kurusetra'
>> app_name = 'nginx-hello'
>> }
>>
>> stages {
>>
>> stage('Clone Repository') {
>> steps {
>> checkout scm
>> }
>> }
>>
>> stage('Build Docker Images') {
>> steps {
>> script {
>> if (env.BRANCH_NAME == 'origin/master') {
>> myapp = 
>> docker.build("${project_id}/${app_name}-prod:${env.BUILD_NUMBER}")
>> } else {
>> myapp = 
>> docker.build("${project_id}/${app_name}-dev:${env.BUILD_NUMBER}")
>> }
>> }
>> }
>> }
>>
>> stage('Push Images') {
>> steps {
>> script {
>> docker.withRegistry('https://docker.xxx.com/kurusetra', 
>> 'harbor') {
>> myapp.push("${env.BUILD_NUMBER}")
>> myapp.push("latest")
>> }
>> }
>> }
>> }
>>
>> stage('Deploy to K8s') {
>> steps {
>> script {
>> if (env.BRANCH_NAME == 'origin/master') {
>> sh "sed -i 
>> 's/${app_name}:latest/${app_name}-prod:${env.BUILD_NUMBER}/g' 
>> deployment.yaml"
>> sh 'kubectl apply -f ./deployment.yaml -n prod'
>> } else {
>> sh "sed -i 
>> 's/${app_name}:latest/${app_name}-dev:${env.BUILD_NUMBER}/g' 
>> deployment.yaml"
>> sh 'kubectl apply -f ./deployment.yaml -n dev'
>> }
>> }
>> }
>> }
>> }
>> }
>>
>
>
> Thanks
> Kurusetra 
>

-- 
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/297a604e-aed8-423b-86c4-89b0baca6fac%40googlegroups.com.


How can I fix "Unreadable data" errors?

2020-03-31 Thread Gianluca
Hi,
I'd like to understand what am I suppose to do to fix the errors showing 
into the "Unreadable data" section of the "Manage Old Data" page of Jenkins 
admin.

Type: org.jenkinsci.plugins.workflow.job.WorkflowRun
Name: Osirium-main scripts pipelines » Cluster Joins » PR-3315 #13
Error: CannotResolveClassException: 
org.jenkinsci.plugins.githubautostatus.BuildStatusAction, 
ConversionException: Invalid reference  Debugging information  
reference : 
../../../../../actions/org.jenkinsci.plugins.githubautostatus.BuildStatusAction/jobParameters/entry[2]/org.jenkinsci.plugins.workflow.multibranch.BranchJobProperty/branch/scm/extensions/hudson.plugins.git.extensions.impl.CloneOption
 
---

Thanks,
Gianluca.

-- 
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/55f19ce6-9452-4eff-bc2f-598e7a357ec3%40googlegroups.com.


Re: Security concern for Gitlab webhook token to Jenkins

2020-03-19 Thread Gianluca
In our case, we are using GitHub but we had similar concerns.
Our solution was to create a little server with NGINX configured to forward 
the webhooks to our Jenkins masters.
In this way, we could achieve the following:
1) Jenkins masters are not exposed at all to internet
2) The configuration are kept inside the server with NGINX (in your the 
token)
3) Changing the Jenkins master only require a change into the NGINX server 
and everything remains the same on GitHub


On Thursday, 19 March 2020 01:05:37 UTC, Jheison Rodriguez wrote:
>
> currently I'm using a webhooks token for trigger Jobs from GitLab to 
> Jenkins, I have a global user so a token set up for all project something 
> like this: https://USERID:APITOKEN@JENKINS_URL/project/YOUR_JOB 
> 
>
> Additionally, when I create a new version of the Jenkins master the token 
> is updated and I need to update in each GitLab project.
>
> I'd like to know if someone has experienced this and had managed this kind 
> of set up in another way? Also to avoid expose the token in the webhooks' 
> URL (security concern) or update it (even with scripts) for each GitLab 
> project.
>

-- 
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/f170fc2c-fabc-40f7-8f41-f8e804355f02%40googlegroups.com.


Re: Injecting environment variables into build

2020-03-13 Thread Gianluca
In my Jenkins setup I don't have "Inject environment variables" in the 
project configuration, so I'm assuming you are using a specific plugin to 
achieve that.
It would be great to know which one.

>From what I can guess you may using this one: 
https://plugins.jenkins.io/envinject/
If so, then the documentation says that the file you specify as to provide 
the environment variables in the standard "Java property file format" and 
if you are passing the .bat file, then you are passing a file with the 
wrong format.


On Wednesday, 11 March 2020 18:11:03 UTC, Sholom Sanders wrote:
>
> My Jenkins is installed on my Windows build machine. I have a directory on 
> this machine which is dedicated to a Jenkins project. 
> Within this directory I have a  .bat file which sets up environment 
> variables, e.g.
>
> set GIT_UPDATE_DIR=$WORKSPACE
> set MDM_SRC_DIR=$GIT_UPDATE_DIR
> set GIT_BRANCH_FULL=MDM_R$branch
> set WRKSPACE=$JENKINS_HOME\\workspace
> set REL_NUMBER=$branch
>
> The source code is in GIT. I want to inject these variables into the build 
> after the SCM. In the Build Environment of the Project Configure section, I 
> selected "Inject environment variables to the build process" and gave the 
> full path of the file on the build machine. In the Build section, the first 
> thing I do is execute a Windows Batch command  which only has "set". When I 
> do the build, the log shows the script being run with all the variables. 
> However, the "set" command does not show any of the variables being 
> available. What am I doing wrong?
>
>

-- 
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/ff2781f0-0870-45a1-b290-e609dadcd4e8%40googlegroups.com.


Pattern in vSphere cloud plugin node label?

2020-03-12 Thread Gianluca
Hi all,
We are using vSphere cloud plugin to start/remove nodes on-demand based on 
the label required and it works great.

So, I'm was thinking to use it for cover another need that at the moment is 
done via external scripts run by the pipeline.

We are using Jenkins to build pull requests done via GitHub, and the build 
and tests requires a sidecar VM on which we run some downstream jobs.
All those sidecar VMs are cloned by a common template.

So I was wondering if the label in vSphere cloud plugin supports patterns 
and creates VM based on those, for example, let's suppose I could put into 
the label something like:

"sidecar-PR-\(\d+\)" ... and then when a pipeline is requesting an agent 
with a label matching, i.e. sidecar-PR-4512, then the vSphere cloud plugin 
will build a node from the template and assign the "sidecar-PR-4512" label.

Is it possible?
Is it something being considered in the past or in working for future 
releases?

Thanks,
Gianluca.

-- 
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/6e878373-f4f6-4e8d-8436-9d67a6cc2ca8%40googlegroups.com.


Maven 2/3 job don't expand variable in rootpom

2012-05-16 Thread Gianluca Chiodaroli
Even if i found a issue here 
https://issues.jenkins-ci.org/browse/JENKINS-5885 i still have the error:

ERROR: No such file 
C:\Jenkins\jobs\MotFis-Test\workspace\test\$AMBIENTE\DOM\pom.xml 

The variable is defined because i use it in svn checkout

Any advice?

Thanks 
Gianluca



publish-over-ftp parametrized

2012-05-04 Thread Gianluca Chiodaroli
Anyone can post an example of configuration with "Parameterized publishing" 
enabled?

Thanks!



M2Release plugin: unable to choose Verioning mode

2012-04-18 Thread Gianluca Chiodaroli
Hi to all, i have installed Jenkins 1.460 and m2release plugin 0.9.1 as a 
windows service.
When i try to release a maven3 multimodule project i'm unable too 
choose Versioning mode, the plugin set the version of parent pom to all 
modules. 
I miss somethings?

Thanks for your help.

Gianluca


Unable to choose Versioning mode

2012-04-18 Thread Gianluca Chiodaroli
Hi to all, i have installed Jenkins 1.460 and m2release plugin 0.9.1 as a 
windows service.
When i try to release a maven3 multimodule project i'm unable too 
choose Versioning mode, the plugin set the version of parent pom to all 
modules. 
I miss somethings?

Thanks for your help.

Gianluca