Comments (15)
It's on my todo list, but I'm currently overflown with other issues :( Not Ontrack related...
from ontrack-plugin.
(initially posted into nemerosa/ontrack#574)
Hi !
While migrating from classic Jenkins jobs definition to Jenkins declarative pipeline definition, I'm looking for examples of usage of ontrack in and ontrack DSL in context of declarative pipelines.
I'm trying to create jobs parameters whose values are automatically populated by ontrack using ontrack DSL. It was possible to do so before declarative pipeline, using ontrack dsl parameter in the UI, but I didn't find an example of doing the same thing in declarative pipeline.
pipeline {
agent any
parameters {
... // how to create dynamic ontrack parameter here ?
}
stages {
stage('Example') {
steps {
...
}
}
}
}
Is it possible ? Could you provide an example if you have any ? A solution to my particular issue or even better, a complete example of declarative pipeline making use of the full potential of ontrack could be a good helper to convice more people to use ontrack, especially since declarative pipeline is the future of jenkins jobs definition.
Thanks a lot :)
PS : I found this, didn't tested yet, need to be investigated on my side, will provide feedback if I can came up with a solution
https://stackoverflow.com/questions/44570163/jenkins-dynamic-declarative-pipeline-parameters#44626376
from ontrack-plugin.
I will make an ontrack
global variable available in the DSL, which will allow to code Ontrack calls using directly the DSL. For example:
node (...) {
...
// Creates a build entry
ontrack.branch('project', 'branch').build(env.BUILD_NUMBER, "Description")
}
See https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/DockerDSL.java for an example of global variable definition.
from ontrack-plugin.
It's on branch feature/19-pipeline
but I have difficulties making it work due to difficulties with CPS constraints. I'm working on it when time allows and it should be available in the next weeks.
from ontrack-plugin.
As of today, I have to use code like:
@NonCPS
def mycall(ontrack) {
ontrack.branch('test', 'master').build(env.BUILD_NUMBER as String, 'For test', true) {
validate 'VS1'
}
}
ontrack {
mycall(delegate)
}
0
Pretty ugly. But I can't get my head around the CPS transformations.
from ontrack-plugin.
First step created: ontrackBuild
... I finally gave up with the CPS transformation, and I'm using regular steps like, for example:
...
ontrackBuild(project: 'proj', branch: 'master', build: env.BUILD_NUMBER)
...
Now, trying to make some integration tests and creation other steps, including calling the Ontrack DSL (as a string)
from ontrack-plugin.
Current progress is : it works in declarative syntax using the following code, but I hate the result so will keep working on it.
properties([
parameters([
[
$class: 'OntrackChoiceParameterDefinition',
description: '',
dsl: "ontrack.branch('APS', 'release').standardFilter(count: 5)",
name: 'RELEASE_NUMBER',
valueProperty: 'name',
sandbox: false
]
])
])
pipeline {
agent any
/* parameters {
... // how to create dynamic ontrack parameter here ?
}*/
stages {
stage('Example') {
steps {
echo 'deployment of config for ' + params.RELEASE_NUMBER
}
}
}
}
Thanks to that I have a parametrizable build where values are filled by ontrack (see picture : https://i.imgur.com/x7Z8XWm.png )
Next challenge is to make it work with a more user friendly syntax
Tested using Jenkins 2.73.2 + ontrack plugin 2.31.1 with ontrack 2.30.4
What I would like to achieve is to define the parameters as below :
pipeline {
agent any
parameters {
ontrackChoiceParam(name: 'RELEASE_NUMBER', description: '...', dsl: '...', valueProperty: '...')
}
stages {
stage('Example') {
steps {
echo 'deployment of config for ' + params.RELEASE_NUMBER
}
}
}
}
But in order to have per-plugin parameters recognised by Jenkins, I think it's needed to define a specific Symbol in your classes that extend ParameterDefinition https://github.com/jenkinsci/ontrack-plugin/search?utf8=%E2%9C%93&q=ParameterDescriptor+&type=
Example here with the credentials plugin where a Symbol annotation is defined
https://github.com/jenkinsci/credentials-plugin/blob/master/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterDefinition.java#L115
More info about this problem and solution for credentials plugin, if it's helpful :
https://issues.jenkins-ci.org/browse/JENKINS-44588
https://github.com/jenkinsci/credentials-plugin/pull/86/files
Cheers
Morgan
from ontrack-plugin.
For my information, do you work with the latest build from the feature/19-pipeline-dsl
branch, or do you use a released version of the plugin?
from ontrack-plugin.
I use the released version of plugin, with versions mentioned in the previous post
Tested using Jenkins 2.73.2 + ontrack plugin 2.31.1 with ontrack 2.30.4
from ontrack-plugin.
Ah ok :) Sorry. You might want to test by building the feature/19-pipeline-dsl
locally and publishing the HPI in your Jenkins instance (management of dependencies can be tricky though...)
from ontrack-plugin.
If you already have a HPI of this version available (as I see you are using travis) I can have a look.
Otherwise I'll try to build it and test it on my side :) (cannot promise when It will be done) and keep you informed, it not urgent for you. I will also test with the Symbol annotation added
from ontrack-plugin.
Available in 2.32.0
from ontrack-plugin.
@dcoraboeuf is it possible to implement the @symbol as suggested in #19 (comment) ? I think it's needed to use ontrack build parameters in native pipeline syntax
from ontrack-plugin.
@dcoraboeuf started working on this, will create an issue and PR when happy with result locally ;)
from ontrack-plugin.
I'm looking forward to it :)
from ontrack-plugin.
Related Issues (20)
- Option to ignore Ontrack failures HOT 1
- Validation - Build result UNSTABLE must be translated into WARNING HOT 1
- Allows use of the ontrack parameter type in declarative pipeline syntax HOT 6
- ontrack trigger is not available in pipeline HOT 15
- Feeding run info for builds and validation runs
- Can not save global configuration with 2.33.0 HOT 2
- Validation step in a parallel stage in a scripted build returns a wrong result HOT 2
- Ontrack trigger available in DSL HOT 1
- Navigation between Jenkins and Ontrack HOT 4
- Validation run with data (pipeline integration)
- Validation run with test summary data
- Allow binding parameters for the OntrackChoiceParameterDefinition DSL HOT 1
- Ontrack trigger on multiple sources HOT 1
- Get a more precise timing for the stage execution time HOT 4
- Improve navigation between Jenkins & Ontrack HOT 1
- Use correct graphql query in graphql example. HOT 1
- Upgrade Ontrack DSL to 3.39.4
- Parsing errors for validation run data metrics should be more explicit
- Pipeline step: allow the description to be passed in validation steps HOT 1
- Calling ontrack from Jenkins using OntrackDSLStep HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ontrack-plugin.