[JIRA] (JENKINS-26354) First time build does not show changelog

2019-04-09 Thread o...@stepura.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Oleg Stepura commented on  JENKINS-26354  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: First time build does not show changelog   
 

  
 
 
 
 

 
 Hi! Thanks for quick reply and sorry I did not react as fast. I discussed internally if this is acceptable to do what you suggested and it was not, but another option to workaround the limitations here was found: JENKINS-54285 I tried using commands from that ticket, it works if we use big enough shallow clone depth (I set it to 100). the only issue I faced was being unable to use sh in a function. It looks buggy. Seems like I cannot simply define a function like this:   

 

def getLastCommitHash() {
  return sh(
returnStdout: true,
script: "git show -s --no-abbrev-commit --pretty=format:%P%n%H%n HEAD"
  ).trim().split("\n").last().trim()
} 

   and the use it:  

 

def otherFunction() {
  def lastCommit = getLastCommitHash()
  // do something else with it expecting lastCommit has one-line string
  return [a, b, c]
} 

 In the example above otherFunction() will return exact unprocessed output of sh command from getLastCommitHash() function. This is weird. I was able to workaround this creating simple functions which only run sh commands and do no post-processing (just return sh output) and other functions that only work with strings and not do anything with sh. Then all those functions are used together inside our main node {} context. 

 

def getHeads() {
  return sh(
returnStdout: true,
script: "git show -s --no-abbrev-commit --pretty=format:%P%n%H%n HEAD"
  )
}

def getLastCommitHash(headsOutput) {
  return headsOutput.trim().split("\n").last().trim()
} 

  then use this in Jenkinsfile: 

 

node("xxx") {
  def headsOutput = getHeads()
  def lastCommitHash = getLastCommitHash(headsOutput)
  // ...
} 

    
 

  
 
 
 
 

 
 
 

 
 
   

[JIRA] (JENKINS-26354) First time build does not show changelog

2019-04-08 Thread o...@stepura.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Oleg Stepura commented on  JENKINS-26354  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: First time build does not show changelog   
 

  
 
 
 
 

 
 Hi! Sorry to resurrect this old issue, but we faced same issue and need some way to solve it. We use multibranch pipeline with scripted Jenkinsfile which should run some stages based on changes we have in a github PR. For this reason we use currentBuild.changeSets and continue collecting changes up to first commit in a branch (until build.previousBuild is null, in a while loop). But this strange issue was discovered and I wonder what are the options to solve this nowadays? Seems like we still don't have a "hidden" option to define parent branch, but I wonder why it is a problem actually. Github solves this somehow in their "commits" Tab. Doesn't any GIT commit point to it's parent commit? Cannot we compare using this info?   Thanks!  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.