Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Added Jenkinsfile (#1)
Browse files Browse the repository at this point in the history
Adds basic Jenkinsfile to project, and fixes some file permission and multiplatform testing issues.

Co-authored-by: Joaquim Neto <[email protected]>
  • Loading branch information
Joaquimmnetto and Joaquimmnetto authored Aug 16, 2021
1 parent 6d8eeb1 commit 9f8ff4a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!groovy
@Library('github.com/wooga/[email protected]') _

withCredentials([string(credentialsId: 'atlas_plugins_sonar_token', variable: 'sonar_token')]) {
buildGradlePlugin platforms: ['macos','windows', 'linux'], sonarToken: sonar_token
}
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package wooga.gradle.dotnetsonar.tasks.internal
import org.gradle.api.Project
import org.gradle.process.ExecSpec


class OSOps {

private static String osName = System.getProperty("os.name").toLowerCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class SonarScannerInstaller {
unzipper.unzip(zippedFile, installationDir)

def scannerFile = findScannerExecutableFile(installationDir)
scannerFile.with {
readable = true
executable = true
}

return scannerFile
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,4 @@ class OSOpsSpec extends ProjectSpec {
e.message == "File ${falseFile.absolutePath} does not exists"
}




}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package wooga.gradle.dotnetsonar.tasks.internal

import nebula.test.ProjectSpec
import org.gradle.process.ExecSpec

import static wooga.gradle.dotnetsonar.utils.SpecUtils.execDotnetApp

class SonarScannerInstallerSpec extends ProjectSpec {

Expand All @@ -21,10 +22,9 @@ class SonarScannerInstallerSpec extends ProjectSpec {
then: "sonar scanner executable should be executing"
scannerExec.exists()
scannerExec.canExecute()
scannerExec.canRead()
scannerExec.name == "SonarScanner.MSBuild.exe"
def execRes = new GradleShell(project).execute { ExecSpec it ->
it.executable = scannerExec.absolutePath
}
def execRes = execDotnetApp(project, scannerExec)
execRes.stdOutString.contains("Using the .NET Framework version of the Scanner for MSBuild")
execRes.execResult.exitValue == 1
}
Expand Down
22 changes: 22 additions & 0 deletions src/test/groovy/wooga/gradle/dotnetsonar/utils/SpecUtils.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
package wooga.gradle.dotnetsonar.utils

import groovy.json.StringEscapeUtils
import org.gradle.api.Project
import wooga.gradle.dotnetsonar.tasks.internal.GradleShell
import wooga.gradle.dotnetsonar.tasks.internal.OSOps
import wooga.gradle.dotnetsonar.tasks.internal.Shell
import wooga.gradle.dotnetsonar.tasks.internal.ShellResult


class SpecUtils {

static ShellResult execDotnetApp(Project project, File app) {
Shell shell = new GradleShell(project)
if(isWindows()) {
return shell.execute { exec ->
exec.executable = app.absolutePath
}
} else {
def mono = OSOps.findInOSPath(shell, "mono").orElseThrow {
throw new FileNotFoundException("Could not find 'mono' executable in OS path")
}
return shell.execute { exec ->
exec.executable = mono.absolutePath
exec.args = [app.absolutePath]
}
}
}

static File emptyTmpFile(String name) {
File file = new File(name)
file.createNewFile()
Expand Down

0 comments on commit 9f8ff4a

Please sign in to comment.