jenkinsci / ontrack-plugin

ontrack plug-in for Jenkins
https://plugins.jenkins.io/ontrack/
MIT License
9 stars 6 forks source link

Calling ontrack from Jenkins using OntrackDSLStep #64

Open raj333921 opened 4 years ago

raj333921 commented 4 years ago

Using below snippet we are not able to generate Use the provided DSL script in Jenkins image image

How can i make usingText to true by using ontrackDSLStep? Plugin version: ontrack@3.4.1 image

But if i use below configuration, I am able to see the content as per expected. configure { node -> node / builders / 'net.nemerosa.ontrack.jenkins.OntrackDSLStep' { usingText true injectEnvironment 'BRANCH' injectProperties '' ontrackLog true sandbox false ignoreFailure false scriptText '''println "BRANCH = ${BRANCH}"

def myBranch = "${BRANCH}" if (myBranch.startsWith('branches/')) { myBranch = myBranch - 'branches/' } myBranch = myBranch.replaceAll('/', '-')

def ontrackBranch = myBranch if (ontrackBranch.endsWith('x')) { ontrackBranch = ontrackBranch - 'x' }

dcoraboeuf commented 4 years ago

I think you could configure the step without the configure and use directly ontrackDsl, like documented at https://github.com/jenkinsci/ontrack-plugin/blob/master/JOB_DSL.md#dsl-step

ontrackDsl {
         // Ontrack DSL script
         script(String value)
         // Injects environment variables
         // Can be called several times
         environment(String... names)
         // Inject property values
         properties(String properties)
         // Enables or disables the log
         log(boolean enabled = true)
}

Don't try to set the usingText directly - this is converted internally to ScriptLocation by the Job DSL code - better use the ontrackDsl method - it's done for this