Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40667

Support of Rundeck usage in Pipeline script

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Am looking for help on how to use Rundeck within pipeline script (Jenkinsfile). For quite sometime now, I have been searching the Net but could not find useful leads.

      Any pointers would be much appreciated.

      NOTE:

      1) As a workaround, I installed Rundeck CLI tool in the Jenkins master and have written short shell scripts which are then embedded within the main Jenkinsfile.

        Attachments

          Activity

          Hide
          beezus Brian Barker added a comment -

          I also want to call rundeck from declarative pipeline scripts. There doesn't seem to be any syntax available to do this. It's really unfortunate as moving to the declarative pipeline has really cleaned up jenkins for us.

          Our hack is to have another parameterized job that just calls rundeck, as the Rundeck plugin works in the jenkins UI. We then trigger that job from our multibranch pipeline scripts.

          Show
          beezus Brian Barker added a comment - I also want to call rundeck from declarative pipeline scripts. There doesn't seem to be any syntax available to do this. It's really unfortunate as moving to the declarative pipeline has really cleaned up jenkins for us. Our hack is to have another parameterized job that just calls rundeck, as the Rundeck plugin works in the jenkins UI. We then trigger that job from our multibranch pipeline scripts.
          Hide
          beezus Brian Barker added a comment - - edited

          I discovered in some recent update to Jenkins we have the ability to call Rundeck from Pipeline. In the non-declarative pipeline world, it is:

          step([$class: "RundeckNotifier",
                includeRundeckLogs: true,
                jobId: "99999999-9999-9999-9999-999999999999"
                nodeFilters: "",
                options: """
                         PARAM_1=value1
                         PARAM_2=value2
                         PARAM_3=
                         """,
                rundeckInstance: "Default",
                shouldFailTheBuild: true,
                shouldWaitForRundeckJob: true,
                tags: "",
                tailLog: true])

          The declarative pipeline doesn't appear to have a keyword for it, but we can call the code all the same as a script step:

          steps {
            script {
              step([$class: "RundeckNotifier",
                    includeRundeckLogs: true,
                    jobId: "99999999-9999-9999-9999-999999999999"
                    nodeFilters: "",
                    options: """
                             PARAM_1=value1
                             PARAM_2=value2
                             PARAM_3=
                             """,
                    rundeckInstance: "Default",
                    shouldFailTheBuild: true,
                    shouldWaitForRundeckJob: true,
                    tags: "",
                    tailLog: true])
            }
          }

          I have both versions running in different builds now.

          Show
          beezus Brian Barker added a comment - - edited I discovered in some recent update to Jenkins we have the ability to call Rundeck from Pipeline. In the non-declarative pipeline world, it is: step([$class: "RundeckNotifier" ,       includeRundeckLogs: true ,       jobId: "99999999-9999-9999-9999-999999999999"       nodeFilters: "",       options: """                PARAM_1=value1                PARAM_2=value2                PARAM_3=                """,       rundeckInstance: "Default" ,       shouldFailTheBuild: true ,       shouldWaitForRundeckJob: true ,       tags: "",       tailLog: true ]) The declarative pipeline doesn't appear to have a keyword for it, but we can call the code all the same as a script step: steps {   script {     step([$class: "RundeckNotifier" ,           includeRundeckLogs: true ,           jobId: "99999999-9999-9999-9999-999999999999"           nodeFilters: "",           options: """                    PARAM_1=value1                    PARAM_2=value2                    PARAM_3=                    """,           rundeckInstance: "Default" ,           shouldFailTheBuild: true ,           shouldWaitForRundeckJob: true ,           tags: "",           tailLog: true ])   } } I have both versions running in different builds now.
          Hide
          kevin_seidler Kevin Seidler added a comment -

          Thank you very much for sharing! It works very well.

          Show
          kevin_seidler Kevin Seidler added a comment - Thank you very much for sharing! It works very well.
          Hide
          hades32 Martin Ra added a comment -

          Awesome, thanks!

          Show
          hades32 Martin Ra added a comment - Awesome, thanks!
          Hide
          johnmj John Mohan added a comment -

          Hi - I get the below exception while using the above declarative pipeline snippet from Brian with Rundeck plugin 3.5.4 and 3.6.4 installed on Jenkins 2.138.2;

          Caused by: java.lang.IllegalArgumentException: Could not instantiate {includeRundeckLogs=true, jobId=2a1b41c7-3fbb-xxxxxx-xxxxxx, nodeFilters=, options=, rundeckInstance=my_rundeck, shouldFailTheBuild=true, shouldWaitForRundeckJob=true, tags=[], tailLog=true} for RundeckNotifier(rundeckInstance: String, jobId: String, options: String, nodeFilters: String, tags: String, shouldWaitForRundeckJob: boolean, shouldFailTheBuild: boolean, includeRundeckLogs: boolean, tailLog: boolean, jobUser: String, jobPassword: String, jobToken: String):

          java.lang.ClassCastException: org.jenkinsci.plugins.rundeck.RundeckNotifier.tags expects class java.lang.String but received class java.util.ArrayList

           

          Any idea how to resolve?

          Show
          johnmj John Mohan added a comment - Hi - I get the below exception while using the above declarative pipeline snippet from Brian with Rundeck plugin 3.5.4 and 3.6.4 installed on Jenkins 2.138.2; Caused by: java.lang.IllegalArgumentException: Could not instantiate {includeRundeckLogs=true, jobId=2a1b41c7-3fbb-xxxxxx-xxxxxx, nodeFilters=, options=, rundeckInstance=my_rundeck, shouldFailTheBuild=true, shouldWaitForRundeckJob=true, tags=[], tailLog=true} for RundeckNotifier(rundeckInstance: String, jobId: String, options: String, nodeFilters: String, tags: String, shouldWaitForRundeckJob: boolean, shouldFailTheBuild: boolean, includeRundeckLogs: boolean, tailLog: boolean, jobUser: String, jobPassword: String, jobToken: String): java.lang.ClassCastException: org.jenkinsci.plugins.rundeck.RundeckNotifier.tags expects class java.lang.String but received class java.util.ArrayList   Any idea how to resolve?
          Hide
          csarre Cédric SARRE added a comment -

          John Mohan
          Hello,

          I met the same issue on yesterday, and I loggued an issue (https://issues.jenkins-ci.org/browse/JENKINS-54537).

          Show
          csarre Cédric SARRE added a comment - John Mohan Hello, I met the same issue on yesterday, and I loggued an issue ( https://issues.jenkins-ci.org/browse/JENKINS-54537 ).
          Hide
          aairey Andy Airey added a comment -

          This ticket should actually be in-progress as there remain to be no docs for it?
          But it actually works (pipeline support for the rundeck plugin).

          BTW I don't have such issues on my environment regarding the tags field.

          Show
          aairey Andy Airey added a comment - This ticket should actually be in-progress as there remain to be no docs for it? But it actually works (pipeline support for the rundeck plugin). BTW I don't have such issues on my environment regarding the tags field.
          Hide
          sentatr senthilkumar Murugesan added a comment - - edited

          Hi,

           

          I've tried with this pipeline command and getting the error like below.

           

          Pipeline Script:-

          step([$class: "RundeckNotifier",
          includeRundeckLogs: true,
          jobId: "***********",
          nodeFilters: "",
          options: """
          """,
          rundeckInstance: "rundeck",
          shouldFailTheBuild: true,
          shouldWaitForRundeckJob: true,
          tags: "",
          tailLog: true])

           

          Error:-

           
          [Pipeline]

          stepRundeck configuration is not valid ![Pipeline] }

          [Pipeline] // node[Pipeline] End of PipelineERROR: Rundeck configuration is not valid !
          Finished: FAILURE

          I've already installed the Rundeck plugin & validated the credentials,  the same working in free style project. Not sure, what i'm missing here?

          Show
          sentatr senthilkumar Murugesan added a comment - - edited Hi,   I've tried with this pipeline command and getting the error like below.   Pipeline Script:- step([$class: "RundeckNotifier", includeRundeckLogs: true, jobId: "***********", nodeFilters: "", options: """ """, rundeckInstance: "rundeck", shouldFailTheBuild: true, shouldWaitForRundeckJob: true, tags: "", tailLog: true])   Error:-   [Pipeline] stepRundeck configuration is not valid ! [Pipeline] } [Pipeline] // node [Pipeline] End of PipelineERROR: Rundeck configuration is not valid ! Finished: FAILURE I've already installed the Rundeck plugin & validated the credentials,  the same working in free style project. Not sure, what i'm missing here?

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            mramanathan Ramanathan M
            Votes:
            6 Vote for this issue
            Watchers:
            13 Start watching this issue

              Dates

              Created:
              Updated: