Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48119

editing the existing declarative jenkinsfile in pipeline editor

    XMLWordPrintable

Details

    • Blue Ocean 1.4 - beta 3, Blue Ocean 1.5 - beta 1

    Description

      Hello,

      I have created jenkinsfile ( declarative pipeline) and no issues with the stages /build is running- but I have not created this via the blue ocean editor.

      But I want to edit it via the blue ocean editor and I cannot do it.
      I can see the pipeline in the blue ocean and when I click on edit option - I see a blank screen.

      so is this not possible to edit the declarative pipeline ( which is not created in editor ) in blue ocean pipeline editor?

      Regards,
      Ashwin

      Attachments

        Activity

          vivek Vivek Pandey added a comment -

          Hi ashsy_009

          Please provide declarative script that reproduces this issue. Without that we do not know how to reproduce it.

           

          vivek Vivek Pandey added a comment - Hi ashsy_009 ,  Please provide declarative script that reproduces this issue. Without that we do not know how to reproduce it.  
          vivek Vivek Pandey added a comment -

          We don't know how to reproduce it, please reopen with reproducible test case.

          vivek Vivek Pandey added a comment - We don't know how to reproduce it, please reopen with reproducible test case.
          pino_alu Pino Alu added a comment -

          Same issue for me as well.  We are using Bitbucket repo.  My jenkinsfile is attached and we cannot edit Jenkinsfile using Blue Ocean editor.Jenkinsfile

          pino_alu Pino Alu added a comment - Same issue for me as well.  We are using Bitbucket repo.  My jenkinsfile is attached and we cannot edit Jenkinsfile using Blue Ocean editor. Jenkinsfile
          kshultz Karl Shultz added a comment -

          TLDR version:
          pino_alu, I figured out how to fix your Pipeline up. Try wrapping that withSonarQube thing inside of a script block. That fixed it up for me. Note that I am running on bleeding edge Blue Ocean 1.5-SNAPSHOT code, so, your mileage may vary. But I was at least able to see it fail, and figure out how to fix it. Might work for you too.

          Long version:
          I'm taking a look at this now, and can confirm pino_alu's report that his provided Jenkinsfile doesn't show up in the editor, even though it is seen by the Declarative validator as a valid pipeline. What I did was, create a brand new repo on a Bitbucket server, and upload this Jenkinsfile exactly to its master branch. Then I created a new pipeline in Blue Ocean using that repo as its basis. Note that I did not expect the build of this pipeline to succeed - Pino has different maven and jdk tool labels, so I didn't expect it to just work like magic. And that part actually worked just fine - Blue Ocean (and the command line Jenkinsfile linter, for that matter) both told me what was wrong.

          ✔ ~/Bitbucket/jenkins-48119 [master L|…1] 
          15:43 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile
          Errors encountered validating Jenkinsfile:
          WorkflowScript: 47: Tool type "maven" does not have an install of "Maven_3.0.5" configured - did you mean "null"? @ line 47, column 11.
                 maven 'Maven_3.0.5'
                       ^
          
          WorkflowScript: 48: Tool type "jdk" does not have an install of "jdk1.8" configured - did you mean "null"? @ line 48, column 9.
                 jdk 'jdk1.8'
                     ^
          
          

          Interestingly, when I deleted the tools block, and commented out the withSonarQubeEnv block, things worked:

          // withSonarQubeEnv('AzureSonarServer') {
              // sh 'mvn clean test package sonar:sonar -Dsonar.host.url=http://sonarsrv.abc.com:9000/sonar -Dsonar.login=31b8fe1ce4d179e11af2154a7b594dbaf21aa46d'
          // }
          

          So we know that the combination of deleting that tools block AND deleting the withSonarQubeEnv block, got the editor to behave. Time for some process of elimination. I added JDK and Maven installs to my instance, matching the names in Pino's Jenkinsfile. This got me past Declarative complaining about tools not being valid, so, that's great! And it worked. It loaded into the editor and everything.

          Next step was to un-comment the withSonarQubeEnv block so that would be processed. Basically we were back where we started, only this time, with matching Maven and JDK listings in Global Tool Config. And we were back to being broken, even though the Jenkinsfile shows as being okay:

          ✔ ~/Bitbucket/jenkins-48119 [master|✔] 
          16:24 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile
          Jenkinsfile successfully validated.
          

          On a whim, I decided to wrap Pino's withSonarQubeEnv thing in a script block. Like this (pardon the messy formatting, I'm trying to change as little as I can here):

              script {
                  withSonarQubeEnv('AzureSonarServer') {
          		sh 'mvn clean test package sonar:sonar -Dsonar.host.url=http://sonarsrv.abc.com:9000/sonar -Dsonar.login=31b8fe1ce4d179e11af2154a7b594dbaf21aa46d'
          				}
                }
          

          Now let's revalidate with the CLI linter:

          ✔ ~/Bitbucket/jenkins-48119 [master|✔] 
          16:29 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile
          Jenkinsfile successfully validated.
          

          I rescaned the MBP project, and launched Blue Ocean, and...ta-da! It works!

          It looks like the Declarative validator isn't complaining about that withSonarQube thing, and maybe it should be, since wrapping it inside a script block looks to have fixed everything right up. I'd be curious to see if abayer has any thoughts on that.

          pino_alu (and others) - just keep in mind that once you start putting things in script blocks, the Editor has very little control over what's in there. Those blocks are meant for when you need to escape the guardrailed environment of Declarative, and do something more elaborate. Validating non-Declarative code inside of an editor built entirely for Declarative wouldn't be realistic. But we can at least make sure it doesn't break.

          I hope that's some help?

          kshultz Karl Shultz added a comment - TLDR version : pino_alu , I figured out how to fix your Pipeline up. Try wrapping that withSonarQube thing inside of a script block. That fixed it up for me. Note that I am running on bleeding edge Blue Ocean 1.5-SNAPSHOT code, so, your mileage may vary. But I was at least able to see it fail, and figure out how to fix it. Might work for you too. Long version : I'm taking a look at this now, and can confirm pino_alu 's report that his provided Jenkinsfile doesn't show up in the editor, even though it is seen by the Declarative validator as a valid pipeline. What I did was, create a brand new repo on a Bitbucket server, and upload this Jenkinsfile exactly to its master branch. Then I created a new pipeline in Blue Ocean using that repo as its basis. Note that I did not expect the build of this pipeline to succeed - Pino has different maven and jdk tool labels, so I didn't expect it to just work like magic. And that part actually worked just fine - Blue Ocean (and the command line Jenkinsfile linter, for that matter) both told me what was wrong. ✔ ~/Bitbucket/jenkins-48119 [master L|…1] 15:43 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile Errors encountered validating Jenkinsfile: WorkflowScript: 47: Tool type "maven" does not have an install of "Maven_3.0.5" configured - did you mean "null"? @ line 47, column 11. maven 'Maven_3.0.5' ^ WorkflowScript: 48: Tool type "jdk" does not have an install of "jdk1.8" configured - did you mean "null"? @ line 48, column 9. jdk 'jdk1.8' ^ Interestingly, when I deleted the tools block, and commented out the withSonarQubeEnv block, things worked: // withSonarQubeEnv('AzureSonarServer') { // sh 'mvn clean test package sonar:sonar -Dsonar.host.url=http://sonarsrv.abc.com:9000/sonar -Dsonar.login=31b8fe1ce4d179e11af2154a7b594dbaf21aa46d' // } So we know that the combination of deleting that tools block AND deleting the withSonarQubeEnv block, got the editor to behave. Time for some process of elimination. I added JDK and Maven installs to my instance, matching the names in Pino's Jenkinsfile. This got me past Declarative complaining about tools not being valid, so, that's great! And it worked. It loaded into the editor and everything. Next step was to un-comment the withSonarQubeEnv block so that would be processed. Basically we were back where we started, only this time, with matching Maven and JDK listings in Global Tool Config. And we were back to being broken, even though the Jenkinsfile shows as being okay: ✔ ~/Bitbucket/jenkins-48119 [master|✔] 16:24 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile Jenkinsfile successfully validated. On a whim, I decided to wrap Pino's withSonarQubeEnv thing in a script block. Like this (pardon the messy formatting, I'm trying to change as little as I can here): script { withSonarQubeEnv('AzureSonarServer') { sh 'mvn clean test package sonar:sonar -Dsonar.host.url=http://sonarsrv.abc.com:9000/sonar -Dsonar.login=31b8fe1ce4d179e11af2154a7b594dbaf21aa46d' } } Now let's revalidate with the CLI linter: ✔ ~/Bitbucket/jenkins-48119 [master|✔] 16:29 $ java -jar ~/bin/jenkins-cli.jar -auth admin:admin -s http://127.0.0.1:8080/jenkins declarative-linter < Jenkinsfile Jenkinsfile successfully validated. I rescaned the MBP project, and launched Blue Ocean, and...ta-da! It works! It looks like the Declarative validator isn't complaining about that withSonarQube thing, and maybe it should be, since wrapping it inside a script block looks to have fixed everything right up. I'd be curious to see if abayer has any thoughts on that. pino_alu (and others) - just keep in mind that once you start putting things in script blocks, the Editor has very little control over what's in there. Those blocks are meant for when you need to escape the guardrailed environment of Declarative, and do something more elaborate. Validating non-Declarative code inside of an editor built entirely for Declarative wouldn't be realistic. But we can at least make sure it doesn't break. I hope that's some help?
          pino_alu Pino Alu added a comment -

          That worked.  Thank You!

          pino_alu Pino Alu added a comment - That worked.  Thank You!

          People

            vivek Vivek Pandey
            ashsy_009 Ashwin Y
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: