by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Gregory Paciga
    @gpaciga
    are there examples of configuring a JTE job with JobDSL? I saw an issue in the old repo discussing it, but can't find anything in the docs
    Gregory Paciga
    @gpaciga
    ah nevermind, found it under factory { templateBranchProjectFactory { ... } }
    Miguel Quintero
    @miqui
    hi, newbie question: how do i configure a specific build agent? (similar to what is done in the traditional Jenkinsfile)
    steven-terrana
    @steven-terrana

    hey @miqui - JTE uses the scripted pipeline syntax. so configuring a build agent would be done the same was as Scripted pipelines.

    if you’re looking to configure a single build agent across the entire pipeline run then you could wrap the whole template in a node block:

    node(“someNodeLabel”){
      step1()
      step2()
    }
    Miguel Quintero
    @miqui
    ok, cool.. thanks @steven-terrana , thanks for your time, i also see what looked like another example using node in the library block... thanks
    Vincent Brouillet
    @Vince-Cercury
    How do I check if a lib or step exists?
    I want to call that step if it exists or do something else if it does not. Is there a more graceful way than try/catch around the call
    steven-terrana
    @steven-terrana
    @Vince-Cercury
    if( getBinding().hasStep(“stepName”) ){
      stepName()
    } else {
      // do something else
    }
    Vincent Brouillet
    @Vince-Cercury
    Thanks
    Vincent Brouillet
    @Vince-Cercury
    Upgrading from 1.5 to 1.7.1. My job dsl is broken, the config template part. Looking at job XML config after upgrading plugin and setting up the config again I don't see any difference. Any tip or example?
    Vincent Brouillet
    @Vince-Cercury
    Found how to do it. I'll raise a doc PR
    Chris Bolton
    @Gl4di4torRr

    application_environment is null when passing into call function

    What is the problem?

    [Pipeline] End of Pipeline hudson.remoting.ProxyException: java.lang.NullPointerException: 
    Cannot get property 'release' on null object at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)

    We know that the app_env is NOT being passed into our deploy_to call method but we are unable (so far) to determine where the object is not being assigned.

    What have we tried?

    Here is our parent config:

    allow_scm_jenkinsfile = false
    
    application_environments{
        dev{
            long_name = "Development"
        }
    }
    
    libraries{
        merge=true
    }
    
    template_methods{
    deploy_to dev
    }

    Here is our parent Jenkinsfile:

    deploy_to()

    Here is our deploy_to.groovy:

    void call(def app_env){
        String release = app_env.release // Null Pointer occurs here b/c app_env is null
    }

    Here is the app (latest) config:

    application_environments{
        dev{
                release = "myapp"
            }
    }
    
    libraries{
        openshift
    }
    steven-terrana
    @steven-terrana

    hey @Gl4di4torRr!

    in your parent config, change:

    template_methods{
      deploy_to dev
    }

    To

    template_methods{
      deploy_to
    }

    and then in your parent Jenkinsfile update it to:

    deploy_to dev

    and you should be golden

    2 replies

    some more explanation:

    the template_methods block exists to tell JTE what steps you expect to invoke from the pipeline template (parent Jenkinsfile) in the event that after loading hte libraries and creating any default step implementations one of those methods has not been implemented to go create a no-op step to avoid “method not defined” errors.

    then - the Jenkinsfile (pipeline template) is where you’d actually use the step - and pass the input argument

    Jackie Weng
    @jemerald
    Is there any documentation on setup JTE pipeline config at the folder level with Job DSL?

    I figured out how to setup the JTE on multibranch pipeline based on an old declined PR

    multibranchPipelineJob(path) {
        configure {
            it / factory(class: 'org.boozallen.plugins.jte.job.TemplateBranchProjectFactory') {
                filterBranches(true)
            }
        }
    }

    But the folder setup code in that PR seems to be specific to Github Org folder :(

    steven-terrana
    @steven-terrana

    hey @jemerald.

    If you checkout the job-dsl api-viewer on your Jenkins instance (<JENKINS_URL>/plugin/job-dsl/api-viewer/index.html#path/folder) it shows the DSL syntax.

    for example..

    folder("my-test-folder"){
      properties{
        templateConfigFolderProperty{
          tier{
            configurationProvider{
              scmPipelineConfigurationProvider{
                baseDir("something")
                scm{
                  gitSCM{ ... } 
                }
              }
            }
          }
        }
      }
    }
    jzr1991
    @jzr1991
    Hi @steven-terrana, great work (and support on this channel too). A question that I think relates a little to one above - is there a nice convention for allowing teams to insert a step in to the pipeline?
    By that I mean, let's say I have a simple pipeline template that mandates a build, test, and deploy. But then a team comes along and wants to use it, but also go above and beyond by adding in a static_code_analysis after test, to improve upon the basic mandatory steps I've defined. Without having a variation of the pipeline in pipeline_templates, is there a way? We might have lots of teams wanting to add lots of extra steps and I'm wary of getting to a place where we have 50 pipeline variations to suit all these cases. Thanks!
    steven-terrana
    @steven-terrana

    hmmm.

    the closest thing to that right now would be the Default Step Implementation which lets users dynamically “create” a step from their pipeline configuration file.

    it’s pretty limited to what it can do though.. you just provide a container image and a script path / command and it uses the Docker Pipeline Plugin to execute the command in teh container image specified.

    but that’s how i try to get around creating libraries for random things.

    one thing you could maybe do is rely exclusively on the lifecycle hook stuff?

    basically let teams configure a library source (scoped probably to just them) and then they can build their own steps.

    so if they wanted to run some custom stuff before the template they could create an @Init step?
    or for after the pipeline they could create an @CleanUp or @Notify step?

    if they wanted to inject functionality before/after a step in the template they could use the @BeforeStep and @AfterStep functionality?

    this isn’t an ideal solution but i can’t think of a cleaner way right now

    do you have any suggestions for the syntax of how something like that might work?

    the risk with that second approach would be that users could then override the steps in the template they’re inheriting. but maybe that’s okay for your use case?
    Vincent Brouillet
    @Vince-Cercury
    Hi. I'm a little confuse on how to create a simple pipeline with JTE. Not a multi branch one. I'm running JTE 1.7.1
    It looks like I can specify in line config and template. But not from scm. And where do I supply lib?
    Jackie Weng
    @jemerald
    Thanks @steven-terrana I didn't know about the DSL api-viewer, that helped a lot.

    I'm currently trying to configure the multibranch pipeline to auto build branches, PRs, and tags.
    While branches and PRs builds fine, the tags doesn't seems to trigger auto-build. Here' the multibranch pipeline log:

    Checking tag test-tag2 from <my-repo>
    ‘pipeline_config.groovy’ found
    Met criteria
    Changes detected: test-tag2 (null → 98aa7a282ac0b30a4a3015be52de0867edc47aa5)
    No automatic build triggered for test-tag2

    Jackie Weng
    @jemerald
    ah, nevermind, it's not JTE related
    steven-terrana
    @steven-terrana
    @Vince-Cercury - currently you can’t specify libraries at the indiviudal Pipeline Job level. you would need to either add the libs globally in Manage Jenkins > Configure System > Jenkins Templating Engine or create a Folder for the pipeline job to be in and then add the libs to this new Folder.
    Vincent Brouillet
    @Vince-Cercury
    Ok thanks
    Vincent Brouillet
    @Vince-Cercury
    Is there a doc or example jobdsl for pipelineJob
    I'm getting an error providePipelineTemplate and providePipelineConfig must be specified
    If I look at api doc, the example shows how to load a normal Jenkins file
    Vincent Brouillet
    @Vince-Cercury

    I'm trying to do it inline, without scm

    But reading above, has a ticket been created for "regular pipeline jobs + JTE from SCM?"

    I'm trying to use readFileFromWorkspace

    definition{
    templateFlowDefinition{
    template(readFromWorkspace('Jenkinsfile')
    pipelineConfig(readFromWorkspace('path-to-pipeline_config.groovy')
    }
    }
    But getting various error. Looking at the XML generated if configuring from Jenkins UI to try to convert to JobDsl

    Vincent Brouillet
    @Vince-Cercury
    ok I got it now.
    So should I create a ticket to make it read from scm?
    steven-terrana
    @steven-terrana

    @Vince-Cercury i’ve created jenkinsci/templating-engine-plugin#100 that i believe captures this use case.

    feel free to comment on the issue if i didn’t appropriately capture the feature request!

    Mahendranath Rekapally
    @getmahen

    Hi @steven-terrana.

    We are using Bitbucket server. Running into an issue with JTE plugin NOT obtaining the pipeline_config.groovy file in the App's repo for Pull Requests but it is obtaining pipeline_config.groovy file from the Governance repo. Here is the issue description:

    Issue description:
    Let say I have a Pull Request (PR) from branch A to master branch. Both branches have pipeline_config.groovy in root directory. But when the PR triggers Jenkins build, templating engine doesn't obtain pipeline_config.groovy of any branch, it only obtains pipeline_config.groovy in Governance repo

    If the build is triggered by branch commit, then templating engine works fine (obtain pipeline_config.groovy in both source repo and Governance repo and merges it) - This works fine!
    I see there are issues reported already on this. Would like to know if you are actively working on a fix for this OR if there is a workaround I can use to make this work.

    steven-terrana
    @steven-terrana

    @getmahen - i am looking into a fix for this but i can’t make any promises on timeline.

    In the meantime, a work around would be to create a governance tier that points to the repository’s pipeline_config.groovy file.

    Not super convenient, but would work around the issue.

    JoshD
    @jd0x
    Hello, is there a migration guide for > 1.6 ?
    When I did a migration on my test instance, it caused the configurations to disappear in the console.
    cc: @steven-terrana
    JoshD
    @jd0x
    re: ⚠️ this upgrade introduces a new feature that changes the JTE configuration in the Jenkins Console. This means that existing Job DSL scripts or the like will need to be updated accordingly.” from release notes.
    steven-terrana
    @steven-terrana

    hey @jd0x - are you using job DSL to create your jobs?

    the primary difference from 1.6+ is that Governance Tiers now have a dropdown to specify if you want to define the configuration information from SCM or in the Jenkins Console.

    If you select “From SCM” the configuration to fill out is the same as pre 1.6

    JoshD
    @jd0x
    GM @steven-terrana - negative, we are using Jenkinsfiles and pipeline_config's running code in lib sources. It is failing to run the pipeline, were there syntax changes elsewhere? Might be that I need to update the SCM configuration in the Console
    steven-terrana
    @steven-terrana

    if there are specific error messages you can share i oughta be able to help.

    if you’re getting a message about a method not being defined or whatever it’s probably an SCM configuration needed to fetch the libs & set the configuration file

    JoshD
    @jd0x
    ah - that sounds about right. I have my jobs defined as Multi-branch Jobs with the JTE configuration option. When I performed the upgrade it looks like it caused the configurations in the console to change resulting in the error:
    [Pipeline] End of Pipeline
    org.boozallen.plugins.jte.config.TemplateConfigException: Could not determine pipeline template.
    Is it a matter of updating the SCM configurations in the console to fix this?
    steven-terrana
    @steven-terrana
    yeah
    would need to reconfigure that Governance Tier to pull from the same place it used to.
    JoshD
    @jd0x
    Great! Thank you so much, I’ll be performing our teams uprade later this evening.
    In the console, we only configure a pipeline configuration and library source.
    I don’t think we are using the governance tier? unless that is the library source