Incorporate Jenkins plugin for Azure Functions (#43)
This commit is contained in:
Родитель
fb11a35118
Коммит
f074255964
|
@ -30,6 +30,11 @@ node {
|
|||
}
|
||||
|
||||
stage('Deploy') {
|
||||
// Deploy function app
|
||||
dir('function-app') {
|
||||
azureUtil.deployFunctionApp()
|
||||
}
|
||||
|
||||
// Deploy data app
|
||||
withEnv(["ACR_NAME=${azureUtil.acrName}", "ACR_LOGIN_SERVER=${azureUtil.acrLoginServer}", "ACR_USERNAME=${azureUtil.acrUsername}", "ACR_PASSWORD=${azureUtil.acrPassword}"]) {
|
||||
azureUtil.deployDataApp(targetEnv, azureUtil.config.EAST_US_GROUP)
|
||||
|
|
|
@ -63,6 +63,21 @@ def prepareEnv(String targetEnv) {
|
|||
).trim()
|
||||
}
|
||||
|
||||
def deployFunctionApp() {
|
||||
def appName = sh(
|
||||
script: "az functionapp list -g ${config.COMMON_GROUP} --query [0].repositorySiteName | tr -d '\"'",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
sh """
|
||||
export COMMON_GROUP=${config.COMMON_GROUP}
|
||||
export FUNCTION_APP=${appName}
|
||||
mvn clean package
|
||||
"""
|
||||
|
||||
azureFunctionAppPublish azureCredentialsId: 'azure-sp', resourceGroup: config.COMMON_GROUP, appName: appName, filePath: '**/*.jar,**/*.json', sourceDirectory: "target/azure-functions/${appName}"
|
||||
}
|
||||
|
||||
def deployWebApp(String resGroup, String dockerFilePath) {
|
||||
def appName = sh(
|
||||
script: "az webapp list -g ${resGroup} --query [0].name | tr -d '\"'",
|
||||
|
@ -114,31 +129,9 @@ def deployDataApp(String targetEnv, String resGroup) {
|
|||
export DATA_APP_CONTAINER_PORT=${config.DATA_APP_CONTAINER_PORT}
|
||||
export TARGET_ENV=${targetEnv}
|
||||
cd data-app
|
||||
mvn clean fabric8:resource
|
||||
|
||||
cat target/fabric8/namespace.yml
|
||||
cat target/fabric8/secrets.yml
|
||||
cat target/fabric8/deployment.yml
|
||||
cat target/fabric8/service.yml
|
||||
|
||||
# Jenkins plugin doesn't support apply namespace
|
||||
kubectl apply -f target/fabric8/namespace.yml
|
||||
mvn clean fabric8:resource fabric8:apply
|
||||
"""
|
||||
|
||||
acsDeploy azureCredentialsId: 'azure-sp', configFilePaths: 'data-app/target/fabric8/namespace.yml', containerService: 'acs | Kubernetes', enableConfigSubstitution: true, resourceGroupName: resGroup, sshCredentialsId: 'acs-ssh'
|
||||
acsDeploy azureCredentialsId: 'azure-sp', configFilePaths: 'data-app/target/fabric8/deployment.yml', containerService: 'acs | Kubernetes', enableConfigSubstitution: true, resourceGroupName: resGroup, sshCredentialsId: 'acs-ssh'
|
||||
acsDeploy azureCredentialsId: 'azure-sp', configFilePaths: 'data-app/target/fabric8/service.yml', containerService: 'acs | Kubernetes', enableConfigSubstitution: true, resourceGroupName: resGroup, sshCredentialsId: 'acs-ssh'
|
||||
|
||||
// Alternatively, we can use kubernetesDeploy, which is more general
|
||||
// def masterHost = sh(
|
||||
// script: "az acs show -g ${resGroup} -n 'acs' --query 'masterProfile.fqdn' | tr -d '\"'",
|
||||
// returnStdout: true
|
||||
// ).trim()
|
||||
// print masterHost
|
||||
// kubernetesDeploy configs: 'data-app/target/fabric8/namespace.yml', credentialsType: 'SSH', kubeConfig: [path: ''], secretName: '', ssh: [sshCredentialsId: 'acs-ssh', sshServer: masterHost], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
|
||||
// kubernetesDeploy configs: 'data-app/target/fabric8/deployment.yml', credentialsType: 'SSH', kubeConfig: [path: ''], secretName: '', ssh: [sshCredentialsId: 'acs-ssh', sshServer: masterHost], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
|
||||
// kubernetesDeploy configs: 'data-app/target/fabric8/service.yml', credentialsType: 'SSH', kubeConfig: [path: ''], secretName: '', ssh: [sshCredentialsId: 'acs-ssh', sshServer: masterHost], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
|
||||
|
||||
sh """
|
||||
# Check whether there is any redundant IP address
|
||||
ip_count=\$(az network public-ip list -g ${resGroup} --query "[?tags.service=='${targetEnv}/data-app'] | length([*])")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM jenkins:2.60.3
|
||||
FROM jenkins/jenkins:lts
|
||||
|
||||
USER root
|
||||
|
||||
|
@ -35,4 +35,5 @@ RUN /usr/local/bin/install-plugins.sh \
|
|||
job-dsl \
|
||||
groovy \
|
||||
azure-app-service \
|
||||
azure-acs
|
||||
azure-acs \
|
||||
azure-function
|
||||
|
|
|
@ -38,7 +38,7 @@ items:
|
|||
spec:
|
||||
containers:
|
||||
- name: "jenkins"
|
||||
image: "microsoft/java-on-azure-jenkins-master:0.3"
|
||||
image: "microsoft/java-on-azure-jenkins-master:0.5"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
- containerPort: 50000
|
||||
|
|
Загрузка…
Ссылка в новой задаче