Upload Build Artifact to Github as Release in Jenkins

This mail service volition show how to automate the release process of a Java Spider web Application (Educatee Enrollment Application developed using MYSQL DB with Hide ORM in a REST based Jersey2 Leap environment) using Jenkins Continuous Integration – upload the release artifacts to release repository. The job configured using this post must be run only later on uploading the snapshot artifacts into the snapshot repository equally explained in the before post Automating the Deployment and Upload of Snapshot Java Artifacts using Jenkins on Windows. The details of the actual application are explained in the earlier post given past the link Building Coffee Web Application Using Bailiwick of jersey REST With Spring.

1. Generate SSH Keys for Github (without passphrase)

Jenkins does not support passphrases for SSH Keys and and so generate the SSH Key for Gihub account without passphrase. Follow the directions given nether Generating SSH Keys, generate a SSH Key without passphrase and upload to Github account.

2. Strength Jenkins to run as user with SSH Central

On Windows, Jenkins uses the SSH Key of the user information technology is running as, which is located under C:\Users<username>.ssh. Hence, Jenkins must be run equally the user with 'username'.

Type 'services.msc' in a control prompt to open up Services Direction. Correct click on the Jenkins service and select Properties.

Jenkins Services Management

From the Jenkins Properties windows, navigate to Log on tab. Choose Log on every bit 'This business relationship', enter the details of the account (use the Browse option to choose/cheque the name of the account) and click Ok. The account credentials will more often than not friction match the log in account for the Windows as shown in the snapshot below

Jenkins Logon

One time the changes are saved, restart the Jenkins service from the Services Direction by Right clicking on Jenkins service and choose Restart as shown below

Jenkins Restart

three. Install Plugins

On the Jenkins Dashboard, navigate to Manage Jenkins –> Manage Plugins equally shown in the snapshot below.

Jenkins Manage Plugins

Install the following plugins and restart Jenkins for the changes to accept consequence.

  • Jenkins Release Plugin (for Maven release)

4. Configure Organisation

On the Jenkins Dashboard, navigate to Manage Jenkins –> Configure System as shown in the snapshot below.

Jenkins Configure System

Go along to the Maven Release Plug-in section. Enable Nexus-Pro back up, enter the Nexus URL, Nexus User Credentials and Salvage the changes.

Jenkins Nexus-Pro

5. Create a New Jenkins Chore

From the Jenkins Dashboard, click on "New Chore" to create a new job. Enter a name for the job and choose "Build a maven2/iii project" as choice and click on OK as shown below.

Jenkins New Job

From the New Job Configuration screen, proceed to the Source Code Direction section and specify the Git Repository URL for the project every bit shown below. From the additional behaviors section, click on "Add" and select Check out to specific local branch. Enter the branch proper noun as master and Relieve the changes.

Jenkins Source Code Management for Release

Proceed to the Build Environment section, enable Maven Release Build pick and enter the release goals.

Jenkins Maven Release Build

Keep to the Build section, enter the maven goals for building a snapshot every bit shown below and Save the changes.

Jenkins Build

Go on to the Build Settings section. Select the option for Email Notification and enter the values for the email recipients every bit shown beneath. Salve the changes.

Jenkins Email Notifications

half-dozen. Configure settings.xml

In guild to upload the congenital Maven artifacts to the artifactory server, configure the Jenkins settings.xml establish in C:\Program Files (x86)\Jenkins\tools\hudson.tasks.Maven_MavenInstallation\Maven_3.1\conf folder with the aforementioned parameters as found in the default settings.xml (normally establish nether C:\Program Files\Apache Software Foundation\apache-maven-3.1.0\conf for a Windows machine) of the Maven installation on the organisation.

Typically, the server section for staging repository needs to be configured with httpHeaders in the settings.xml for the Maven Release.

                      1                      2                      3                      4                      v                      6                      7                      eight                      nine                      10                      11                      12                      thirteen                      xiv                      fifteen                    
                                              <servers>                                                                          <server>                                                                          <id>sonatype-nexus-staging</id>                                                                          <username>username</username>                                                                          <password>password</password>                                                                          <configuration>                                                                          <httpHeaders>                                                                          <property>                                                                          <name>User-Amanuensis</name>                                                                          <value>Maven m2Release (java:${coffee.vm.version} ${env.BUILD_TAG }</value>                                                                          </holding>                                                                          </httpHeaders>                                                                          </configuration>                                                                          </server>                                                </servers>                                          

Also, a profile department needs to be configured for the PGP Signature, the details of how to Generate PGP Signatures with Maven can be institute from the section Generate a Fundamental Pair at How to Generate PGP Signatures With Maven

                      i                      two                      three                      iv                      5                      six                      7                      8                      ix                      ten                      xi                      12                      thirteen                    
                                              <profiles>                                                                          <profile>                                                                          <id>gpg-release</id>                                                                          <properties>                                                                          <gpg.passphrase>passphrase</gpg.passphrase>                                                                          <gpg.useagent>truthful</gpg.useagent>                                                                          <gpg.defaultKeyring>false</gpg.defaultKeyring>                                                                          <gpg.homedir>C:/Users/Sara/AppData/Roaming/gnupg</gpg.homedir>                                                                          <gpg.publicKeyring>C:/Users/Sara/AppData/Roaming/gnupg/pubring.gpg</gpg.publicKeyring>                                                                          <gpg.secretKeyring>C:/Users/Sara/AppData/Roaming/gnupg/secring.gpg</gpg.secretKeyring>                                                                          </properties>                                                                          </profile>                                                </profiles>                                          

6. Update pom.xml

The pom.xml file for the project needs to exist configured with the post-obit plugins under the build department.

  • maven-enforcer-plugin
  • maven-release-plugin
                      one                      two                      iii                      4                      5                      6                      7                      8                      9                      10                      11                      12                      thirteen                      14                      xv                      16                      17                      18                      nineteen                      twenty                      21                      22                      23                      24                      25                      26                      27                      28                      29                      30                      31                      32                      33                      34                      35                      36                      37                      38                      39                      forty                      41                      42                    
                                              <build>                                                                          <plugins>                                                                          <plugin>                                                                          <groupId>org.apache.maven.plugins</groupId>                                                                          <artifactId>maven-enforcer-plugin</artifactId>                                                                          <version>1.2</version>                                                                          <executions>                                                                          <execution>                                                                          <id>enforce-maven</id>                                                                          <goals>                                                                          <goal>enforce</goal>                                                                          </goals>                                                                          <configuration>                                                                          <rules>                                                                          <requireMavenVersion>                                                                          <version>(,2.one.0),(2.1.0,2.2.0),(2.2.0,)</version>                                                                          <message>Maven two.ane.0 and 2.2.0 produce incorrect GPG signatures                                                                          and checksums respectively.</bulletin>                                                                          </requireMavenVersion>                                                                          </rules>                                                                          </configuration>                                                                          </execution>                                                                          </executions>                                                                          </plugin>                                                                          </plugins>                                                                                                                          <pluginManagement>                                                                          <plugins>                                                                          <plugin>                                                                          <groupId>org.apache.maven.plugins</groupId>                                                                          <artifactId>maven-release-plugin</artifactId>                                                                          <version>two.4.2</version>                                                                          <configuration>                                                                          <tagBase>https://github.com/elizabetht/StudentEnrollmentWithREST/tags</tagBase>                                                                          <mavenExecutorId>forked-path</mavenExecutorId>                                                                          <useReleaseProfile>simulated</useReleaseProfile>                                                                          <arguments>-Psonatype-oss-release</arguments>                                                                          </configuration>                                                                          </plugin>                                                                          </plugins>                                                                          </pluginManagement>                                                </build>                                          

Update the pom.xml with a profile section for the maven-gpg-plugin

                      ane                      2                      iii                      iv                      five                      6                      7                      8                      nine                      10                      11                      12                      13                      14                      15                      16                      17                      eighteen                      nineteen                      twenty                      21                      22                    
                                              <profiles>                                                                          <profile>                                                                          <id>sign</id>                                                                          <build>                                                                          <plugins>                                                                          <plugin>                                                                          <groupId>org.apache.maven.plugins</groupId>                                                                          <artifactId>maven-gpg-plugin</artifactId>                                                                          <executions>                                                                          <execution>                                                                          <id>sign-artifacts</id>                                                                          <phase>verify</phase>                                                                          <goals>                                                                          <goal>sign</goal>                                                                          </goals>                                                                          </execution>                                                                          </executions>                                                                          </plugin>                                                                          </plugins>                                                                          </build>                                                                          </profile>                                                </profiles>                                          

Add together a distribution management section to pom.xml to specify the snapshot and staging repository URLs.

                      ane                      2                      three                      four                      5                      6                      vii                      viii                      ix                      10                    
                                              <distributionManagement>                                                                          <repository>                                                                          <id>sonatype-nexus-staging</id>                                                                          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>                                                                          </repository>                                                                          <snapshotRepository>                                                                          <id>sonatype-nexus-snapshots</id>                                                                          <url>https://oss.sonatype.org/content/repositories/snapshots</url>                                                                          </snapshotRepository>                                                </distributionManagement>                                          

8. Build Now

One time the to a higher place configuration steps are consummate, click on "Build At present" under the Jenkins –> Upload REST Release Artifacts (or the respective Job name) to build the project based on the configuration.

The panel output has the detailed logs of what steps were initiated by the configuration and the upshot of the entire build. Verify that the build succeeds.

9. Perform Maven Release

Once the build succeeds and snapshots are uploaded to the snapshot repository, click on "Perform Maven Release" nether Jenkins –> Upload REST Release Artifacts (or the corresponding Job name) to outset the Maven Release process.

Verify that the Release version and the next Evolution Version are correct. Enable 'Specify custom SCM comment prefix' to enter a custom SCM Annotate. Enable 'Specify custom SCM tag' to enter a custom SCM tag. Click on Schedule Maven Release Build.

Jenkins Perform Maven Release

Once the release procedure succeeds, the staging repository will be uploaded with the release artifacts.

Thus the entire process of performing the maven release of artifacts to the staging repository and triggering emails to the recipients can be automated with a click of a push button through Jenkins. The staging repository can be taken and so through the steps of Close (if its all the same open) and Release to complete the promotion of the artifacts.

cardilloenty1981.blogspot.com

Source: http://elizabetht.github.io/blog/2014/02/05/jenkins-release-upload

0 Response to "Upload Build Artifact to Github as Release in Jenkins"

إرسال تعليق

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel