JIRA and Jenkins Integration

Step 1. Setup JIRA and Jenkins env with Docker images
docker pull atlassian/jira-software
docker volume create –name jiraVolume
docker run -v jiraVolume:/var/atlassian/application-data/jira –name=”jira” -d -p 8080:8080 atlassian/jira-software
docker pull jenkins/jenkins:lts
docker run –name jenkins -d -p 9090:8080 -p 50000:50000 jenkins/jenkins:lts

Step 2. Configure JIRA on http://locahost:8080/ and create project DevOps

Step 3. Configure Jenkins on http://locahost:9090/ and install/setup JIRA Trigger Plugin

Step 4. Create WebHook on JIRA

https://github.com/jenkinsci/jira-trigger-plugin

Step 5. create a Freestyle job on Jenkins

Step 6. Add a comment “build this please” on JIRA, then verify it triggered the Jenkins job successfully!

ref:
https://www.atlassian.com/software/jira/guides/expand-jira/jql#jql-syntax
https://github.com/jenkinsci/jira-trigger-plugin

create Maven project in Jenkins and deploy to Jboss

  1. in Jenkins select create new item, give name as "java-web-project", type as "Maven Project". Keep all default value, only add "wildfly:deploy" in "Build => Goals and options" then apply and save.
  2. in /var/lib/jenkins/workspace/, run maven command to create webapp:
    mvn archetype:generate -DgroupId=com.pythondesign.web -DartifactId=java-web-project -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
    you will get files:

    
    (base) ubuntu@ubunu2004:/var/lib/jenkins/workspace/java-web-project$ tree
    .
    ├── pom.xml
    ├── src
    │   └── main
    │       ├── resources
    │       └── webapp
    │           ├── index.jsp
    │           └── WEB-INF
    │               └── web.xml
3. update pom.xml as below:
```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mkyong.web</groupId>
  <artifactId>java-web-project</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>java-web-project Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>java-web-project</finalName>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
         <plugins>
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>2.1.0.Beta1</version>
            <configuration>
                <hostname>localhost</hostname>
                <port>9990</port>
                <username>admin</username>
                <password>pas8word@</password>
            </configuration>
        </plugin>
         </plugins>
        </pluginManagement>
  </build>
</project>
  1. you can test it with command:
    mvn package
    mvn wildfly:deploy
  2. now we can click "Build Now" in Jenkins, check the console, you will get:
    BUILD SUCCESS! and verify the webapp on jboss:
    http://192.168.0.43:8090/java-web-project/index.jsp

install jenkins_2.235.1 on ubuntu20

  1. sudo apt install openjdk-8-jdk
  2. wget -q -O – https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add –
  3. sudo sh -c ‘echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
  4. sudo apt update
  5. sudo apt install jenkins
  6. sudo ufw allow 8080
  7. (jenkins_url)/restart – Forces a restart without waiting for builds to complete.

Setting Up Jenkins
To set up your new Jenkins installation, open your browser, type your domain or IP address followed by port 8080, http://your_ip_or_domain:8080 and screen similar to the following will be displayed:
undefined
Use the following command to print the password on your terminal:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the password from your terminal, paste it into the Administrator password field and click Continue.
undefined
follow the page to setup admin user and url, then you can logon your Jenkins:
http://192.168.0.43:8080/