Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-07-24 Thread nadim
I am currently running into a similar issue as you Idan. Within my jenkins 
file I push git tags, which sets off a trigger in Jenkins, building another 
build, and the continues in an infinite loop. I looked into the [ci skip] 
plugin but it does not work. I looked at your link on stack overflow but it 
doesn't look like it is a solution to my problem. 

On Saturday, March 25, 2017 at 12:53:34 PM UTC-7, Idan Adar wrote:
>
> At last, resolved using parameters, when and expression blocks.
> See here: 
> http://stackoverflow.com/questions/43016942/can-a-jenkins-job-be-aborted-with-success-result
>

-- 
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/0eb72ce8-7d35-4782-8ea9-f820693b0e87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Idan Adar
At last, resolved using parameters, when and expression blocks.
See 
here: 
http://stackoverflow.com/questions/43016942/can-a-jenkins-job-be-aborted-with-success-result

-- 
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/fe5bcea7-305e-45b2-b9e1-750bc243574b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Idan Adar
I am now attempting to solve this use the environment, when and expression 
blocks.
Could some please take a 
look? 
http://stackoverflow.com/questions/43016942/can-a-jenkins-job-be-aborted-with-success-result

-- 
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/3c884828-05c1-4038-8864-e0e5fae9e727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Idan Adar
Thus far I have tried:

* success ("...") -- build stops with "failed" status
* sh "exit 0" -- build doesn't stop (continues to the next stage in the 
pipeline)

I think "exit 0" is the way to go, but didn't yet figure out exactly how... 

On Saturday, March 25, 2017 at 1:01:15 PM UTC+3, Stephen Connolly wrote:
>
> Skipping polling from the git plugin is not an option for branch sources
>
> The branch source tracks last revision built for each branch and fires a 
> build of the current revision is not equal to the last.
>
> What you want is a build step that stops the build with an "ignore" status 
> of some sort.
>
> On Sat 25 Mar 2017 at 09:52, Idan Adar > 
> wrote:
>
>> As Mark mentioned, the alternative is to trigger an exception... (which 
>> will in turn show the row in red color).
>> I do it as follows. After checking out, if a git commit includes "[ci 
>> skip]" I use a "success" keyword (this keyword does not exit) hence the 
>> build stops.
>>
>> I would love for this keyword to exist, so that the job will stop with a 
>> green row instead of a red row... Is this possible?
>>
>> stage ("Checkout SCM") {
>> steps {
>> script {
>>STAGE_NAME = "Checkout SCM"
>>
>>checkout scm
>>result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", 
>> returnStatus: true) 
>>if (result == 0) {
>>   echo ("'ci skip' spotted in git commit. Aborting.")
>>   success ("'ci skip' spotted in git commit. Aborting.")
>>}
>> }
>> }
>> }
>>
>> -- 
>> 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-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/cd25bb36-d893-4281-a04e-d5a6bb54f6b8%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Sent from my phone
>

-- 
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/720a5799-1150-462a-afe8-55d3e01636ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Stephen Connolly
Skipping polling from the git plugin is not an option for branch sources

The branch source tracks last revision built for each branch and fires a
build of the current revision is not equal to the last.

What you want is a build step that stops the build with an "ignore" status
of some sort.

On Sat 25 Mar 2017 at 09:52, Idan Adar  wrote:

> As Mark mentioned, the alternative is to trigger an exception... (which
> will in turn show the row in red color).
> I do it as follows. After checking out, if a git commit includes "[ci
> skip]" I use a "success" keyword (this keyword does not exit) hence the
> build stops.
>
> I would love for this keyword to exist, so that the job will stop with a
> green row instead of a red row... Is this possible?
>
> stage ("Checkout SCM") {
> steps {
> script {
>STAGE_NAME = "Checkout SCM"
>
>checkout scm
>result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'",
> returnStatus: true)
>if (result == 0) {
>   echo ("'ci skip' spotted in git commit. Aborting.")
>   success ("'ci skip' spotted in git commit. Aborting.")
>}
> }
> }
> }
>
> --
> 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/cd25bb36-d893-4281-a04e-d5a6bb54f6b8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Sent from my phone

-- 
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/CA%2BnPnMymwUSu6%2BDiUQpgwZdVwZ4t%3DQP81DggRo6iwMX%3Dr_CWSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Idan Adar
As Mark mentioned, the alternative is to trigger an exception... (which 
will in turn show the row in red color).
I do it as follows. After checking out, if a git commit includes "[ci 
skip]" I use a "success" keyword (this keyword does not exit) hence the 
build stops.

I would love for this keyword to exist, so that the job will stop with a 
green row instead of a red row... Is this possible?

stage ("Checkout SCM") {
steps {
script {
   STAGE_NAME = "Checkout SCM"
   
   checkout scm
   result = sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", 
returnStatus: true) 
   if (result == 0) {
  echo ("'ci skip' spotted in git commit. Aborting.")
  success ("'ci skip' spotted in git commit. Aborting.")
   }
}
}
}

-- 
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/cd25bb36-d893-4281-a04e-d5a6bb54f6b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-25 Thread Idan Adar
This answer is promising: http://stackoverflow.com/a/41164841/1530814

The problem is that when using Branch Source as Git (so that these options 
are available in the Jenkins UI, $CHANGE_ID is not available... (my code 
depends on it).
When using Branch Source as GitHub, these options are not available...

-- 
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/5ee93b0d-3dfe-4cdf-9b5b-c52bdb1568a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-24 Thread Idan Adar
The above is not the solution. It simply makes the job not run...

-- 
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/a05675f3-4374-4207-8db6-f9874ad2428c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-23 Thread Idan Adar
Could it be that this is the 
solution? 
http://stackoverflow.com/questions/42798006/how-to-disable-automatic-build-from-scm-change-in-jenkinsfile
The flow in my case is:

PR to GHE > GHE sends pull_request webhook to Jenkins > Jenkins uses the 
Jenkinsfile to run unit tests > Jenkins makes a call to merge the PR to the 
master branch.
The merge to the master branch is essentially a push webhook, so: GHE sends 
a push webhook to Jenkins > Jenkins uses the same Jenkinsfile to run again 
unit tests > there is logic to not-merge in case the branch is the master 
branch > Instead publish to npm > bump the version number > commit & push 
to git.

This time because the the whole thing worked from a checkout of the master 
branch and not based on a PR, the option to "Suppress automatic SCM 
triggering" should hopefully stop the loop from starting...

On Thursday, March 23, 2017 at 4:09:09 PM UTC+2, Idan Adar wrote:
>
> Unfortunately I am not versed enough in programming to add this 
> functionality... 
>
> I think that the workaround will add lots of "red rows" in the job view, 
> because it first has to checkout the repo, check the messages and then 
> abort...
>
> On Thursday, March 23, 2017 at 3:59:07 PM UTC+2, Mark Waite wrote:
>>
>> The git plugin as used in pipeline doesn't support ignoring commits from 
>> certain users, or ignoring commits with certain messages.  Until it does, 
>> you will probably need to "short circuit" and exit from the pipeline after 
>> using git commands to extract the latest commit message from the 
>> repository.  It's not a pretty solution, but it can work now.
>>
>> Another alternative is to fork the git plugin and add the "ignore commits 
>> from specific user" support to the pipeline.
>>
>> Mark Waite
>>
>> On Thu, Mar 23, 2017 at 7:43 AM Idan Adar  wrote:
>>
>>> I should add that the job is of multibranch type.
>>>
>>>
>>> On Thursday, March 23, 2017 at 3:10:51 PM UTC+2, Idan Adar wrote:

 Hi all,

 In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a 
 job from getting re/triggered due to a push event in GitHub?
 For example:

 stage ("Publish to npm") {
steps {
   sh '''
  npm publish
  npm --no-git-tag-version version minor
   '''
   
   sh '''
  git commit -am 'Bumped version number'
  git push
   '''
}
 }

 The "git push" will trigger the push webhook in GitHub that makes a 
 call to Jenkins, which will in turn start the same Jenkinsfile and again 
 bump the version, commit, push and again... a loop.
 How can we not-trigger the job in this scenario?


 -- 
>>> 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-use...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jenkinsci-users/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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/2eb19e36-0fee-45e8-b347-a11f3ff64577%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-23 Thread Idan Adar
Unfortunately I am not versed enough in programming to add this 
functionality... 

I think that the workaround will add lots of "red rows" in the job view, 
because it first has to checkout the repo, check the messages and then 
abort...

On Thursday, March 23, 2017 at 3:59:07 PM UTC+2, Mark Waite wrote:
>
> The git plugin as used in pipeline doesn't support ignoring commits from 
> certain users, or ignoring commits with certain messages.  Until it does, 
> you will probably need to "short circuit" and exit from the pipeline after 
> using git commands to extract the latest commit message from the 
> repository.  It's not a pretty solution, but it can work now.
>
> Another alternative is to fork the git plugin and add the "ignore commits 
> from specific user" support to the pipeline.
>
> Mark Waite
>
> On Thu, Mar 23, 2017 at 7:43 AM Idan Adar > 
> wrote:
>
>> I should add that the job is of multibranch type.
>>
>>
>> On Thursday, March 23, 2017 at 3:10:51 PM UTC+2, Idan Adar wrote:
>>>
>>> Hi all,
>>>
>>> In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a 
>>> job from getting re/triggered due to a push event in GitHub?
>>> For example:
>>>
>>> stage ("Publish to npm") {
>>>steps {
>>>   sh '''
>>>  npm publish
>>>  npm --no-git-tag-version version minor
>>>   '''
>>>   
>>>   sh '''
>>>  git commit -am 'Bumped version number'
>>>  git push
>>>   '''
>>>}
>>> }
>>>
>>> The "git push" will trigger the push webhook in GitHub that makes a call 
>>> to Jenkins, which will in turn start the same Jenkinsfile and again bump 
>>> the version, commit, push and again... a loop.
>>> How can we not-trigger the job in this scenario?
>>>
>>>
>>> -- 
>> 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-use...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/a8f94adf-357e-412e-8665-16c5663a1c05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-23 Thread Mark Waite
The git plugin as used in pipeline doesn't support ignoring commits from
certain users, or ignoring commits with certain messages.  Until it does,
you will probably need to "short circuit" and exit from the pipeline after
using git commands to extract the latest commit message from the
repository.  It's not a pretty solution, but it can work now.

Another alternative is to fork the git plugin and add the "ignore commits
from specific user" support to the pipeline.

Mark Waite

On Thu, Mar 23, 2017 at 7:43 AM Idan Adar  wrote:

> I should add that the job is of multibranch type.
>
>
> On Thursday, March 23, 2017 at 3:10:51 PM UTC+2, Idan Adar wrote:
>
> Hi all,
>
> In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a
> job from getting re/triggered due to a push event in GitHub?
> For example:
>
> stage ("Publish to npm") {
>steps {
>   sh '''
>  npm publish
>  npm --no-git-tag-version version minor
>   '''
>
>   sh '''
>  git commit -am 'Bumped version number'
>  git push
>   '''
>}
> }
>
> The "git push" will trigger the push webhook in GitHub that makes a call
> to Jenkins, which will in turn start the same Jenkinsfile and again bump
> the version, commit, push and again... a loop.
> How can we not-trigger the job in this scenario?
>
>
> --
> 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/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAO49JtHfc7jEz%2BoYG7sj3fQVuVq8BRrSeDyB1N1HwqKHD8E7Gg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to skip a build after a "git push" done by a Jenkinsfile

2017-03-23 Thread Idan Adar
I should add that the job is of multibranch type.

On Thursday, March 23, 2017 at 3:10:51 PM UTC+2, Idan Adar wrote:
>
> Hi all,
>
> In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a 
> job from getting re/triggered due to a push event in GitHub?
> For example:
>
> stage ("Publish to npm") {
>steps {
>   sh '''
>  npm publish
>  npm --no-git-tag-version version minor
>   '''
>   
>   sh '''
>  git commit -am 'Bumped version number'
>  git push
>   '''
>}
> }
>
> The "git push" will trigger the push webhook in GitHub that makes a call 
> to Jenkins, which will in turn start the same Jenkinsfile and again bump 
> the version, commit, push and again... a loop.
> How can we not-trigger the job in this scenario?
>
>
>

-- 
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/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to skip a build after a "git push" done by a Jenkinsfile

2017-03-23 Thread Idan Adar
Hi all,

In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a job 
from getting re/triggered due to a push event in GitHub?
For example:

stage ("Publish to npm") {
   steps {
  sh '''
 npm publish
 npm --no-git-tag-version version minor
  '''
  
  sh '''
 git commit -am 'Bumped version number'
 git push
  '''
   }
}

The "git push" will trigger the push webhook in GitHub that makes a call to 
Jenkins, which will in turn start the same Jenkinsfile and again bump the 
version, commit, push and again... a loop.
How can we not-trigger the job in this scenario?


-- 
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/fcb1b9ad-c18b-487a-96ee-f7b13a447d02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.