I'm trying to use a YAML file as a standard-in to teamcity to pass build parameters. (user will copy the yaml file as stdin) .
which build runner should i use to achieve this. I can find command line as a build runner.but it simply use arguments to a script ? ( i can do the same) but is there any way that i can copy configuration details to teamcity without an argument to a script ?
Jetbrains seems to prefere not do go with yaml. But you can still give XML or Kotlin DSL a try:
You can store project settings in the XML format or in the Kotlin language and define settings programmatically using the Kotlin-based DSL. Kotlin DSL
import jetbrains.buildServer.configs.kotlin.v2019_2.*
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
version = "2021.1"
project {
buildType {
id("HelloWorld")
name = "Hello world"
steps {
script {
scriptContent = "echo 'Hello world!'"
}
}
}
}
Related
As described in this guide I am using ./gradlew buildNativeLambda command to generate zip file containing graalvm native image. I am facing a problem described in this thread so wanted to include resource by passing -H:IncludeResources to my command like below:
./gradlew buildNativeLambda -H:IncludeResources="com/amazonaws/partitions/endpoints.json"
Unfortunately, its failing with Unknown command-line option '-H'. How can I pass this to gradle task?
Seems like the right way to do it is though build.gradle file like below:
graalvmNative {
binaries {
main {
buildArgs "-H:IncludeResources=\"com/amazonaws/partitions/endpoints.json\""
}
}
}
How to provide command line argument to build task?
For instance, I want to download 60 build version from an archive to my local server path.
Could you please suggest how can I achieve this?
Example task:
task download(type: Download) {
src 'http://archiva/repository/test/$version/project-$version.jar'
dest new File(buildDir, '../../../test/project.jar')
username 'username'
password 'password'
}
gradle download version=60
You can use Project Properties for this purpose (see Project Properties)
Example: consider the following task
task hello{
doLast{
println "Hello ${project.findProperty('myProp')}"
}
}
You can pass property value as follows:
./gradlew hello -PmyProp=world
Note you should use another variable name than "version", as version is already a Gradle property attached to the project.
Note 2 : I noticed you are using simple quote for src value, this cannot work. You need to se double-quote for String interpolation ( see here ):
Use:
src "http://archiva/repository/test/$version/project-$version.jar"
instead of:
src 'http://archiva/repository/test/$version/project-$version.jar'
I want to run the SOAPUI project xmls using Gradle script. The GRADLE script should read the project xmls from soapuiInputs.properties file and run automatically all. Please guide me step by step how to create Gradle script to run the SOAPUI projects in Linux server.
Note: We use SOAPUI version 5.1.2.
Probably the simple way is to call the SOAPUI testrunner directly from gradle as Exec task, like you can do from cli.
In gradle you can define the follow tasks (Note that I try it on windows but to do the same on linux as you ask simply you've to change the paths):
// define exec path
class SoapUITask extends Exec {
String soapUIExecutable = 'C:/some_path/SoapUI-5.2.1/bin/testrunner.bat'
String soapUIArgs = ''
public SoapUITask(){
super()
this.setExecutable(soapUIExecutable)
}
public void setSoapUIArgs(String soapUIArgs) {
this.args = "$soapUIArgs".trim().split(" ") as List
}
}
// execute SOAPUI
task executeSOAPUI(type: SoapUITask){
// simply pass the project path as argument,
// note that the extra " are needed
soapUIArgs = '"C:/location/of/project.xml"'
}
To run this task use gradle executeSOAPUI.
This task simply runs a SOAPUI project, however testrunner supports more parameters which you can pass to soapUIArgs string in executeSOAPUI task, take a look here.
Instead of this if you want to deal with more complex testing there is a gradle plugin to launch SOAPUI project, take a look on it here
Hope this helps,
I want to run multiple soapui projects in Gradle script. The SOAPUI project files are kept is following location:
d:/soapui/projects/path/a.xml, b.xml etc
Will be there any Gradle script that it will enter into the above mentioned location and execute the each project one by one using testrunner.bat
As #RaGe comments you can use the gradle SOAPUI plugin. However if you're looking for a more custom way you can proceed as follows.
You can generate a task on Gradle to execute testrunner to run your SOAPUI projects. Then you can create dynamically one task for each project you've in a directory path, and using .depends you can make that all these dynamic generated tasks are called when you call the specific task.
Your build.gradle could be something like:
// task to execute testrunner
class SoapUITask extends Exec {
String soapUIExecutable = '/SOAPUI_HOME/bin/testrunner.bat'
String soapUIArgs = ''
public SoapUITask(){
super()
this.setExecutable(soapUIExecutable)
}
public void setSoapUIArgs(String soapUIArgs) {
this.args = "$soapUIArgs".trim().split(" ") as List
}
}
// empty task wich has depends to execute the
// ohter tasks
task executeSOAPUI(){
}
// get the path where are your projects
def projectsDir = new File(project.properties['soapuiProjectsPath'])
// create tasks dynamically for each project file
projectsDir.eachFile{ file ->
if(file.name.contains('.xml')){
// create the tasks
task "executeSOAPUI${file.name}"(type: SoapUITask){
println "execute project ${file.name}"
soapUIArgs = ' "' + file.getAbsolutePath() +'"'
}
// make the depends to avoid invoke each task one by one
executeSOAPUI.dependsOn "executeSOAPUI${file.name}"
}
}
To invoke this you can do it using the follow command:
gradle executeSOAPUI -PsoapuiProjectsPath=d:/soapui/projects/path/
Note that -P is used to pass the parameter for projects dir.
Recently I wrote an answer on how to write gradle task to run SOAPUI which can be also util, if you want check more details here.
Hope this helps,
I’m using Gradle 2.7. I have the following files in my build"
src/main/environment/dev/aws.properties
src/main/environment/qa/aws.properties
src/main/environment/prod/aws.properties
How do I copy a file into my assembled WAR classpath based on whether someone specifies the environment on the command line when executing a build (e.g. gradle build -Penv=qa)? If the -Penv=xxx flag isn't specified, I’d like the src/main/environment/dev/aws.properties file to be copied into the class path.
It will be:
war {
def env = project.hasProperty('env') ? project.env : 'dev'
from("src/main/environment/$env") {
include('aws.properties')
into('WEB-INF/classes')
}
}
If you need env elsewhere you can define it at the beginning of the script. If you have added src/main/environment to source sets it can be used instead of path.