如何在Jenkinsfile管道中触发OCP CronJob

时间:2020-07-20 20:38:37

标签: jenkins jenkins-pipeline openshift

我的Jenkinsfile具有OCP构建和部署阶段和方法,但是我想向其添加OCP CronJob触发器。我查看了詹金斯的文档,但找不到相关的答案。如果您在下面看到,则有一个ocpDeploy()方法使用openshiftDeploy deploymentConfig: app ...。 OCP CroJob相当于什么?非常感谢您的帮助。

...
stage('Deploy App') {
    steps {
        parallel(
            'my-app': {ocpDeploy("my-app")}, ...
        )
    }
}
stage('Cron Job') {
    steps {
        parallel(
            'networkinbound': { ocpCron("networkinbound") }, ...
        )
    }
} ...

def ocpDeploy(def myAppName) {
    def project = env.PROJECT
    def app = "${project}-${myAppName}
    def namespace = "${project}-${env.MY_BRANCH}"

    withCredentials(...) {...}

    openshiftDeploy deploymentConfig: app, namespace: namespace
}

# What is the CronJob equivalent method?
def ocpCron(def myAppName) {
    def project = env.PROJECT
    def app = "${project}-${myAppName}
    def namespace = "${project}-${env.MY_BRANCH}"

    withCredentials(...) {...}

    openshiftCronJob cronJob: app, namespace: namespace
}

0 个答案:

没有答案