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?
Hello James,
I have added our github organization and our repo consists of Jenkinsfile . Not directly used the multibranch or the pipeline type for declarative pipeline