Artifactory newGradleBuild() - artifactoryDeploy .zip' does not exists, and need to be published - spring-boot

I have a spring boot application where i need to created boot.tar file and i need to exclude all the files created by gradle application plugin
apply plugin: 'war'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile('com.fasterxml.jackson.core:jackson-annotations:2.9.6')
compile('com.fasterxml.jackson.core:jackson-core:2.9.6')
compile('com.fasterxml.jackson.core:jackson-databind:2.9.6')
testCompile('org.springframework.boot:spring-boot-starter-test')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
}
apply plugin: 'application'
application {
mainClassName = 'com.xx.MyMainClass'
}
distZip.enabled = false
distTar.enabled = false
bootDistZip.enabled = false
I also have a generic jenkins pipeline which run the gradle build using jenkins artifactory plugin when i ran the build it failed with the following error
Execution failed for task artifactoryDeploy
File '/workerfs/workspace/mybuild/2/myApp/build/distributions/myapp-x.y.z.zip' does not exists, and need to be published!.zip' does not exists, and need to be published
Updated Jenkinsfile
rtGradle = Artifactory.newGradleBuild()
rtGradle.usesPlugin = false
rtGradle.deployer.deployMavenDescriptors = true
rtGradle.deployer.deployIvyDescriptors= false
rtGradle.deployer server: server, repo: "snapshotLocal"
rtGradle.resolver server: "myartifactoryserver", repo: "virtualLocal"
rtGradle.useWrapper = true
rtGradle.deployer.deployArtifacts = false
rtGradle.run rootDir: ".", buildFile: 'build.gradle', tasks: "clean build artifactoryPublish", buildInfo : <buidINfoObj>

Related

not finding codenarc ruleset using build.gradle

Trying to apply codenarc to a spring boot project, however the gradle build is producing :codenarcMain NO-SOURCE. Please advise on what I am doing wrong.
1) Added plugins to build.gradle
apply plugin: 'groovy'
apply plugin: 'codenarc'
2) Then added the following to the build.gradle
codenarc {
ignoreFailures = true
}
codenarcMain {
reports {
html.enabled = true
}
configFile = file("$rootDir/config/codenarc/rules.groovy")
}
3) created rules definition in the file rules.groovy
$rootDir/config/codenarc/rules.groovy

SonarQube - java/groovy multimodule project scan

I have:
SonarQube v5.6 + Groovy plugin
gradle 3.5
org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5
Configuration:
def sourceProjects = allprojects.findAll { it.file('src/main').exists() }
configure(sourceProjects) {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: "org.sonarqube"
sourceSets.main.java.srcDirs = []
sourceSets.main.groovy.srcDirs = ['src/main/java', 'src/main/groovy']
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile lib.groovy_core
}
}
Project structure:
rootDir
apps
app-backend
app-ui
modules
module 1
module 2
module 3
Whenever I run: $ ./gradlew sonarqube what happens is when it goes through different modules, it does not aggregate sonar reports. It throws in last module scan and overwrites anything that was already stored. So after running this, I just get the results for last modules that gradle executor processed. Can something be done about that?
For what its worth I solved this issue by applying sonar cube to the root project only:
project(':') {
apply plugin: 'org.sonarqube'
}

Could not find method cargo() for arguments

I am trying to deploy war to tomcat with gradle cargo,i am getting error could not found method cargo()
C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle>gradle build
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle\build.gradle' line: 45
What went wrong:
A problem occurred evaluating root project 'SpringMvcUsingGradle'.
Could not find method cargo() for arguments [build_3gitu3al50b7kv8zi1ebj3qsr$runclosure3#302aa00f] on root project 'SpringMvcUsingGradle'.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat-base'
apply plugin: 'com.bmuschko.cargo-base'
ext.tomcatVersion = '7.0.67'
sourceCompatibility = 1.7
buildscript {
repositories {
maven {
url "https://plugins.grdev.net/m2/"
}
}
dependencies {
classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4"
classpath 'com.bmuschko:gradle-cargo-plugin:2.2'
}
}
repositories {
mavenCentral()
}
dependencies {
def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
compile 'org.springframework:spring-context:4.0.0.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.0.RELEASE'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:jstl:1.2'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:jcl-over-slf4j:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'log4j:log4j:1.2.15'
testCompile 'junit:junit:4.7'
}
cargo {
containerId = 'tomcat7x'
port = 8080
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
output = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}
}
war {
version = ''
}
It seems, that you've applied the wrong plugin at the moment. Just change:
apply plugin: 'com.bmuschko.cargo-base'
to
apply plugin: 'com.bmuschko.cargo'
Because, when you apply the com.bmuschko.cargo-base plugin, you have to configure each task individually, according to the plugin description.
And one more, there is no property output, which could be defined within the local closure, but there is an outputFile property, so, your local closure should look like:
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
outputFile = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}

Gradle build for Java project is failing

Below build.gradle file for java project is failing
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
testCompile "log4j:log4j:1.2.9"
testCompile 'org.testng:testng:6.8'
}
test {
// enable TestNG support
task testNGTests(type: Test) {
useTestNG() {
suites 'src/test/resources/testng.xml'
useDefaultListeners = true
}
}
}
Error:
Couldnot find property 'projectDir' on org.gradle.api.tasks.testing.testng.TestNGOptions_Decorated#1595f1bb.
Then I tried in using setting.gradle file with below code:
rootProject.name = 'AutoTest_Gradle'
project(':AutoTest_Gradle').projectDir = 'C:/workspace/AutoTest_Gradle'
Here AutoTest_Gradle is the project name.Then it is failed with below error:
Where:
Settings file 'C:\workspace\AutoTest_Gradle\settings.gradle
What went wrong:`enter code here
A problem occurred evaluating settings 'AutoTest_Gradle'.
Project with path ':AutoTest_Gradle' could not be found.
Can anyone help on this?

Unable to run more than one plugins in gradle

I have configured pmd, checkstyle and findbugs plugins in gradle.build file as i want to maintain the quality the codeline.
Part of my build.gradle property is:
task wrapper(type: Wrapper) {
description = "Generates gradlew (for internal use only)"
gradleVersion = '1.5'
jarFile = 'wrapper/wrapper.jar'
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'findbugs' //TODO: disable findbugs & checkstyle by default.
apply plugin: 'checkstyle'
apply plugin: 'pmd'
pmd.ignoreFailures = true
findbugs.ignoreFailures = true
findbugsMain.enabled = true
findbugsTest.enabled = true
checkstyleTest.enabled = true
checkstyleMain.enabled = true
checkstyle {
configFile = new File(rootDir, "config/checkstyle/checkstyle.xml")
ignoreFailures = true
}
My intention is to get all the warnings/errors for pmd, findbugs and checkstyle.
I am trying gradlew check but i am not able to see any certain behavior. At times findbugs alone runs.
Can anybody suggest where i am missing?
Thanks in advance,
Vijay Bhore
get you list the output of your
./gradlew check
invocation. Usually this should work, though enabling your tasks manually (e.g. 'findbugsMain.enabled = true') shouldnt be necessary.
cheers,
René

Resources