如何通过jenkins脚本化管道创建属性文件

时间:2019-03-06 06:07:33

标签: jenkins-pipeline

我正在创建下面给出的属性块或映射,我想将其写入文件。我找不到从管道代码将属性写入文件的方法。需要帮助弄清楚如何做。

def props = [APPNAME = 'testaoo',
            DEPLOY_ENV = stream,
            DEPLOY_STREAM = stream_num,
            DEPLOY_ENV_TYPE = deploy_env_type,
            BUILD_JOB_ID = env.BUILD_JOB_ID,
            WAS_NDM_AgentURL= getAgentURL(stream),
            WAS_CLUSTER = getClusterName(stream),
            DeployPublishNeeded = 'Yes'
            ]

1 个答案:

答案 0 :(得分:0)

def props = [
    APPNAME : 'testaoo',
    DeployPublishNeeded : 'Yes'
]

def content = props.collect{entry->entry.key+"="+entry.value}.join('\n')

writeFile file: 'a.properties', text: content