2

All flow is working fine locally but it is getting issue on jenkins. I am performing following steps:

1- created simple spring boot sample project downloaded strating from spring.io. Below is the pom

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>13</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

2- On Jenkins -> Project -> Build Now -> Console Output. It just pull the latest code and run maven command

mvn clean install

Jenkins when work on POM, gives following error:

Downloading: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.cassandra:datacenter-microservice:0.0.1 (/var/jenkins_home/workspace/dataservice-microservice/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.2.2.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.2.2.RELEASE/spring-boot-starter-parent-2.2.2.RELEASE.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. and 'parent.relativePath' points at no local POM @ line 5, column 13 -> 

enter image description here

vicky
  • 561
  • 1
  • 7
  • 17
  • 3
    You are using http instead of https cause central repository is only available via https and not via http anymore https://blog.sonatype.com/central-repository-moving-to-https. Furthermore the question is which Maven are you using? – khmarbaise Jan 16 '20 at 13:49
  • 1
    Update to newest version of Maven. – Thorbjørn Ravn Andersen Jan 16 '20 at 13:49
  • @khmarbaise i am using maven 3.0.5. What i need to change? is it jenkins specific or just maven update required? – vicky Jan 16 '20 at 14:12
  • 1
    First I strongly recommend to upgrade you Maven version which is about 6 years old (would help here) ..furthermore I strongly recommend to configure your Jenkins using a `settings.xml` and also start to use a repository manager ...is this inside a corporate environment? – khmarbaise Jan 16 '20 at 14:17
  • That exactly was the issue. I updated the maven and it is working like a charm. Can you please guide me to setup jenkins settings.xml – vicky Jan 16 '20 at 14:41
  • @khmarbaise kindly post your comment as an answer so that i can accept it. And jenkins setup using settings.xml detail would be great. – vicky Jan 16 '20 at 16:21
  • The `settings.xml` should be configured via the [Config File provider plugin](https://plugins.jenkins.io/config-file-provider) afterwards you have to use the correct pipeline code to correctly handle that which is a completely different questions/answer... – khmarbaise Jan 16 '20 at 16:29

2 Answers2

3

You are using http instead of https cause central repository is only available via https and not via http anymore https://blog.sonatype.com/central-repository-moving-to-https.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • 1
    This answer helped me and @khmarbaise pointed out in comments that my maven is old enough to not understand this new repo change or something. Maven version upgrade made my day. Thanks – vicky Jan 17 '20 at 10:53
  • @khmarbaise facing same issue while I have latest POM 4.0 and using https and still getting this issue. Failed to transfer Could not find metadata org.springframework.boot:spring-boot-starter-parent:2.3.0.BUILD-SNAPSHOT/maven-metadata.xml in spring-milestones Downloaded artifact https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/2.3.0.BUILD-SNAPSHOT/maven-metadata.xml Downloaded artifact https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-parent/2.3.0.BUILD-SNAPSHOT/spring-boot-starter-parent-2.3.0.BUILD-20200322.191326-414.pom – Muhammad Siddique Mar 23 '20 at 08:38
  • You are using a SNAPSHOT instead of a release which are only available from different repositories and NOT from central repository..Take a look into the docs of Spring how to use the spring repositories... – khmarbaise Mar 23 '20 at 09:39
  • @ArunGowda add the appropriate `settings.xml` configuration in Jenkins via Config File Provider Plugin is the best ...or maybe you should use a repository manager if you are in a corporate environment.... – khmarbaise Apr 08 '20 at 14:21
0

This parent pom is there in https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter/ repository. Include this repository in your settings.xml

Muthu
  • 51
  • 1
  • 1