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

is there any clean way to avoids redeclared so much withcredentials in every job scripted pipeline

XMLWordPrintable

      i develop one job to do auto installation,and this job need so much user/password,i refer these credentials in my scripted pipeline like below:

      // code placeholder
      

      withCredentials([usernamePassword(credentialsId: 'CDNativePassInfo', usernameVariable: 'CDNATIVE_USER', passwordVariable: 'CDNATIVE_PASSWORD'), usernamePassword(credentialsId: 'ABC_NODE_INFO', usernameVariable: 'ABC_NODE_USER', passwordVariable: 'ABC_NODE_PASSWORD'), usernamePassword(credentialsId: 'BOAPP_TENANT_PWD', usernameVariable: 'BOAPP_TENANT_USER', passwordVariable: 'BOAPP_TENANT_PASSWORD'), usernamePassword(credentialsId: 'CCE_LOGIN_INFO', usernameVariable: 'CCE_LOGIN_USER', passwordVariable: 'CCE_LOGIN_PASSWORD'), usernamePassword(credentialsId: 'CDTEMPLATEBO_JWTKEY', usernameVariable: 'CDTEMPLATEBO_JWTKEY_NAME', passwordVariable: 'CDTEMPLATEBO_JWTKEY_VALUE'), usernamePassword(credentialsId: 'CDBATCHFILEPROCESSBO_JWTKEY', usernameVariable: 'CDBATCHFILEPROCESSBO_JWTKEY_NAME', passwordVariable: 'CDBATCHFILEPROCESSBO_JWTKEY_VALUE'), usernamePassword(credentialsId: 'CDCODEMACHINE_factor', usernameVariable: 'CDCODEMACHINE_factor_NAME', passwordVariable: 'CDCODEMACHINE_factor_VALUE'), usernamePassword(credentialsId: 'CDENERGYPREDICTION_clientsecret', usernameVariable: 'CDENERGYPREDICTION_clientsecret_NAME', passwordVariable: 'CDENERGYPREDICTION_clientsecret_VALUE'), usernamePassword(credentialsId: 'CDENERGYPREDICTION_factor', usernameVariable: 'CDENERGYPREDICTION_factor_NAME', passwordVariable: 'CDENERGYPREDICTION_factor_VALUE'), usernamePassword(credentialsId: 'CDAIRFLOW_factor', usernameVariable: 'CDAIRFLOW_factor_NAME', passwordVariable: 'CDAIRFLOW_factor_VALUE'), usernamePassword(credentialsId: 'CDAIRFLOW_fernet_key', usernameVariable: 'CDAIRFLOW_fernet_key_NAME', passwordVariable: 'CDAIRFLOW_fernet_key_VALUE'), usernamePassword(credentialsId: 'ABC_MYSQL_INFO', usernameVariable: 'ABC_MYSQL_USER', passwordVariable: 'ABC_MYSQL_PASSWORD'), usernamePassword(credentialsId: 'COLDMACHINE_OAUTH', usernameVariable: 'COLDMACHINE_OAUTH_NAME', passwordVariable: 'COLDMACHINE_OAUTH_PWD'), usernamePassword(credentialsId: 'ENERGYPREDICTION_OAUTH', usernameVariable: 'ENERGYPREDICTION_OAUTH_NAME', passwordVariable: 'ENERGYPREDICTION_OAUTH_PWD'), usernamePassword(credentialsId: 'SECURITYVOICE_OAUTH', usernameVariable: 'SECURITYVOICE_OAUTH_NAME', passwordVariable: 'SECURITYVOICE_OAUTH_PWD'), usernamePassword(credentialsId: 'NATIVEBO_DB_PWD', usernameVariable: 'NATIVEBO_DB_NOTCARE', passwordVariable: 'NATIVEBO_DB_PWD'), usernamePassword(credentialsId: 'MYSQL_LOGIN_INFO', usernameVariable: 'MYSQL_UserName', passwordVariable: 'MYSQL_PassWord'), usernamePassword(credentialsId: 'OPENGAUSS_ADMIN_INFO', usernameVariable: 'OPENGAUSS_ADMIN_USER', passwordVariable: 'OPENGAUSS_ADMIN_PWD') ])

      { //to do something }

      i think this code style is not clean code,is there any clean way to refer many credentials in groovy? more clean and beautiful way

            Unassigned Unassigned
            kakamain zhou xin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: