private async parseScmCredentials()

in src/handlers/parameterValidator.ts [82:118]


    private async parseScmCredentials(state: StateConstant, publishProfile: string): Promise<IScmCredentials> {
        let creds: IScmCredentials = Builder.GetDefaultScmCredential();
        if (publishProfile === undefined || publishProfile === "") {
            return creds;
        }

        let xmlProfile: any = undefined;
        await parseString(publishProfile, (error, xmlResult) => {
            if (error) {
                throw new ValidationError(
                    state, ConfigurationConstant.ParamInPublishProfile,
                    "should be a valid XML. Please ensure your publish-profile secret is set in your " +
                    "GitHub repository by heading to GitHub repo -> Settings -> Secrets -> Repository secrets"
                );
            }
            xmlProfile = xmlResult;
        });

        if (this.tryParsePublishProfileZipDeploy(xmlProfile, creds)) {
            Logger.Info('Successfully parsed SCM credential from publish-profile format.');
        } else if (this.tryParseOldPublishProfile(xmlProfile, creds)) {
            Logger.Info('Successfully parsed SCM credential from old publish-profile format.');
        } else if (this.tryParseNewPublishProfile(xmlProfile, creds)) {
            Logger.Info('Successfully passed SCM crednetial from new publish-profile format.');
        } else {
            throw new ValidationError(
                state, ConfigurationConstant.ParamInPublishProfile,
                "should contain valid SCM credentials. Please ensure your publish-profile contains 'ZipDeploy' publish or 'MSDeploy' publish " +
                "method. Ensure 'userName', 'userPWD', and 'publishUrl' exist in the section. You can always acquire " +
                "the latest publish-profile from portal -> function app resource -> overview -> get publish profile"
            );
        }

        core.setSecret(`${creds.username}`);
        core.setSecret(`${creds.password}`);
        return creds;
    }