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

Adding “Perform Maven Release” option from Jenkinsfile

      Is there a way to make the Perform Maven Release option visible under the job created using Jenkinsfile? I have a job that is created manually and it has this option set by selecting the Maven release build option in Configure job->Build environment settings. I am trying to convert this manual job to pipeline job using Jenkinsfile.

          [JENKINS-37867] Adding “Perform Maven Release” option from Jenkinsfile

          Jesse Glick added a comment -

          The M2 Release plugin only works with Maven projects, not freestyle or Pipeline. I doubt something like this would be implemented per se. Better to create a separate job dedicated to running releases, which would have different triggering—for example, no polling or SCM trigger, but a string parameter asking to select the branch to release—and different build steps (mvn -B release:prepare release:perform, probably just pass/fail, no detailed reporting needed).

          Jesse Glick added a comment - The M2 Release plugin only works with Maven projects, not freestyle or Pipeline. I doubt something like this would be implemented per se. Better to create a separate job dedicated to running releases, which would have different triggering—for example, no polling or SCM trigger, but a string parameter asking to select the branch to release—and different build steps ( mvn -B release:prepare release:perform , probably just pass/fail, no detailed reporting needed).

          Harsha B added a comment -

          Hi Jesse,
          Thanks for the response. Ok. That was my plan B. I would like to provide an option to the user in the pipeline job to trigger this maven release job. I am thinking of using jobDSL command to create a Maven release job from Jenkinsfile for every pipeline job that gets created. Is there a way to ensure that this step in Jenkinsfile is run only once (.i.e. the very first time a new pipeline job is created) ? I was thinking may I will set some env variable and run this step based on whether it is set or not. Is there a any other way of doing that?

          Harsha B added a comment - Hi Jesse, Thanks for the response. Ok. That was my plan B. I would like to provide an option to the user in the pipeline job to trigger this maven release job. I am thinking of using jobDSL command to create a Maven release job from Jenkinsfile for every pipeline job that gets created. Is there a way to ensure that this step in Jenkinsfile is run only once (.i.e. the very first time a new pipeline job is created) ? I was thinking may I will set some env variable and run this step based on whether it is set or not. Is there a any other way of doing that?

          Harsha B added a comment -

          Just revisiting this topic to see if there is any new development.Is there any plan to support maven project type as a template for pipeline projects?

          I am currently calling a DSL script from Jenkinsfile to create maven projects for master branch to get around this limitation. Works fine. But woulds like to know if pipelines would provide an option to the users to choose any project template they want in near future?

          Harsha B added a comment - Just revisiting this topic to see if there is any new development.Is there any plan to support maven project type as a template for pipeline projects? I am currently calling a DSL script from Jenkinsfile to create maven projects for master branch to get around this limitation. Works fine. But woulds like to know if pipelines would provide an option to the users to choose any project template they want in near future?

          James Nord added a comment -

          it doesn't make sense as the release job is rarely just the normal job with one maven invocation changed.

          A release job in a pipeline world will generally involve extra tasks such as creating release notes etc etc...

          You can simulate something like this by disabling parallel builds and adding a boolean checkbox "release" then inside your pipeline check if release is "true" and then switch goals and run different steps.

          However if you want a separate "release" and "build" job and are using multi branch pipelines then there is some commercial code that will create jobs from the same source with different pipelines https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#pipeline-custom-factories

          James Nord added a comment - it doesn't make sense as the release job is rarely just the normal job with one maven invocation changed. A release job in a pipeline world will generally involve extra tasks such as creating release notes etc etc... You can simulate something like this by disabling parallel builds and adding a boolean checkbox "release" then inside your pipeline check if release is "true" and then switch goals and run different steps. However if you want a separate "release" and "build" job and are using multi branch pipelines then there is some commercial code that will create jobs from the same source with different pipelines https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#pipeline-custom-factories

          Dennis Hoer added a comment -

          With the advent of git and pull requests, I don't think using maven-release-plugin or maven-version-plugin with a Jenkins pipeline is a good idea. 

          Please take a look at the following for more information: https://stackoverflow.com/a/47338098/4548096

          Dennis Hoer added a comment - With the advent of git and pull requests, I don't think using maven-release-plugin or maven-version-plugin with a Jenkins pipeline is a good idea.  Please take a look at the following for more information: https://stackoverflow.com/a/47338098/4548096

          James Nord added a comment -

          maven CD friendly versions are not ready for the prime time yet IMO. Bugs in plugins and you also need to translate the pom if you want to deploy it (the version with $revision in it is not consumable by maven)

          James Nord added a comment - maven CD friendly versions are not ready for the prime time yet IMO. Bugs in plugins and you also need to translate the pom if you want to deploy it (the version with $revision in it is not consumable by maven )

          Dennis Hoer added a comment - - edited

          teilo I'm not sure what issues you are having, but Maven 3.2.1 and higher should support ${revision}. I'm using this to deploy today with none of those issues mentioned.  See this writeup: https://axelfontaine.com/blog/dead-burried.html.

          Dennis Hoer added a comment - - edited teilo  I'm not sure what issues you are having, but Maven 3.2.1 and higher should support ${revision}. I'm using this to deploy today with none of those issues mentioned.  See this writeup: https://axelfontaine.com/blog/dead-burried.html .

            Unassigned Unassigned
            harsha924 Harsha B
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: