내 pom.xml에서 maven 플러그인을 통해 pmd (checkstyle 및 findbugs도 실행 중)입니다. Jenkins 빌드는 pmd에서보고 한 오류로 인해 실패합니다.젠킨스에서 빌드를 실패하지 않고 pom을 통해 pmd를 실행하는 방법은 무엇입니까?
빌드 단계는 6 개의 모듈을 병렬로 실행하고 그 후에 게시자와 다른 단계를 실행합니다. pmd가 실패하면 전체 빌드가 실패하고 즉시 중지됩니다.
</properties>
<failOnChecks>true</failOnChecks>
</properties>
<!-- ...... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.8</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${version.pmd}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${version.pmd}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-javascript</artifactId>
<version>${version.pmd}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-jsp</artifactId>
<version>${version.pmd}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>my.software</groupId>
<artifactId>build-tools</artifactId>
<version>${version.build-tools}</version>
</dependency>
</dependencies>
<configuration>
<rulesets>
<ruleset>pmd/ruleset.xml</ruleset>
</rulesets>
<failOnViolation>${failOnChecks}</failOnViolation>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Jenkinsfile 그 두 단계가 있습니다 :
이
내 pom.xml 파일에서 발췌입니다stage('modules') {
gitlabCommitStatus('modules') {
parallel Config.stepsForParallel
}
}
stage('Jenkins Code Analysis') {
pmd canRunOnFailed: true, canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
checkstyle canRunOnFailed: true, canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
//findbugs canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', pattern: '', unHealthy: ''
}
두 번째 단계에 도달 할 수 있습니다 전에 빌드에 실패합니다.
플러그인은 파이프 라인을 중지하지 말고 끝내고 실패한 다음 게시자를 실행하여 Jenkins에서 문제를 볼 수 있습니다.
지금까지 속성을 통해 failOnViolation을 설정했지만 끝에 빌드하지 못하게했습니다. 어딘가에서 상태를 확인하고 오류를 호출해야한다고 생각합니다.
이것을 수행하는 더 깨끗한 방법이 있습니까?
먼저 왜 플러그인에 의존성을 정의 했습니까? 또한 Maven을 호출하기 위해 다음과 같이 체크했다 :'mvn --fail-at-end ...'? – khmarbaise
1 : 이것은 동료가 수행했습니다. 나는 그가 그렇게 할 이유가 있다고 생각한다. 아마도 그들을 제거 할 수 있습니다. 2 : 모든 빌드가 자신의 mvn 명령을 실행하기 때문에 --fail-at-end는 아마 작동하지 않을 것입니다. --fail-never는 다른 오류도 억제 할 수 있기 때문에 결코 좋지 않을 것입니다. – Ctwx
플러그인에 이러한 종속성을 추가하는 것은 실제로 의미가 없습니다. 플러그인에 이미 해당 종속성이 있습니다. CI 솔루션을 사용하여 이러한 빌드를 실행하고 있습니까? 그렇다면 maven 호출의 구성을 변경할 수 있습니다. – khmarbaise