<?xml version='1.1' encoding='UTF-8'?>
<project>
  <actions/>
  <description>Pushes schema for graphql-@SERVICE@ from ECR Docker image of commit SHA to Apollo Engine</description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <hudson.plugins.buildblocker.BuildBlockerProperty plugin="build-blocker-plugin">
      <useBuildBlocker>false</useBuildBlocker>
    </hudson.plugins.buildblocker.BuildBlockerProperty>
    <org.datadog.jenkins.plugins.datadog.DatadogJobProperty plugin="datadog">
      <emitOnCheckout>false</emitOnCheckout>
    </org.datadog.jenkins.plugins.datadog.DatadogJobProperty>
    <com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer">
      <doNotScan>false</doNotScan>
    </com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
    <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin="naginator">
      <optOut>false</optOut>
    </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>GIT_COMMIT</name>
          <description>Commit version to checkout</description>
          <defaultValue></defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>AWS_REGION</name>
          <description></description>
          <defaultValue>us-east-1</defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
        <hudson.model.StringParameterDefinition>
          <name>ECR_REPOSITORY</name>
          <description></description>
          <defaultValue>086679231553.dkr.ecr.us-east-1.amazonaws.com/graphql-@SERVICE@</defaultValue>
          <trim>false</trim>
        </hudson.model.StringParameterDefinition>
        <hudson.model.ChoiceParameterDefinition>
          <name>ENV</name>
          <description>Name of environment used for Apollo Engine schema tag</description>
          <choices class="java.util.Arrays$ArrayList">
            <a class="string-array">
              <string>qa</string>
              <string>prod</string>
            </a>
          </choices>
        </hudson.model.ChoiceParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
    <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents">
      <maxConcurrentPerNode>0</maxConcurrentPerNode>
      <maxConcurrentTotal>0</maxConcurrentTotal>
      <categories class="java.util.concurrent.CopyOnWriteArrayList"/>
      <throttleEnabled>false</throttleEnabled>
      <throttleOption>project</throttleOption>
      <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
      <paramsToUseForLimit></paramsToUseForLimit>
    </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
  </properties>
  <scm class="hudson.plugins.git.GitSCM" plugin="git">
    <configVersion>2</configVersion>
    <userRemoteConfigs>
      <hudson.plugins.git.UserRemoteConfig>
        <url>git@github.com:theorchard/graphql-@SERVICE@.git</url>
        <credentialsId>@GITHUB_CREDENTIAL_ID@</credentialsId>
      </hudson.plugins.git.UserRemoteConfig>
    </userRemoteConfigs>
    <branches>
      <hudson.plugins.git.BranchSpec>
        <name>${GIT_COMMIT}</name>
      </hudson.plugins.git.BranchSpec>
    </branches>
    <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
    <submoduleCfg class="list"/>
    <extensions>
      <hudson.plugins.git.extensions.impl.AuthorInChangelog/>
    </extensions>
  </scm>
  <assignedNode>ny-deploy</assignedNode>
  <canRoam>false</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <builders>
    <hudson.tasks.Shell>
      <command>if [ -f ~/.docker/config.json ]; then
  rm -rf ~/.docker/config.json
fi

echo $GIT_COMMIT
docker --version

# Login to ECR
aws ecr get-login-password --region us-east-1 \
    | docker login --username AWS --password-stdin 086679231553.dkr.ecr.us-east-1.amazonaws.com

docker pull ${ECR_REPOSITORY}:${GIT_COMMIT}

docker run -e ENV=${ENV} -e APOLLO_KEY=service:graphql-theorchard:${APOLLO_ENGINE_API_KEY} -i ${ECR_REPOSITORY}:${GIT_COMMIT} yarn apollo:push ${ENV} --serviceURL=https://${ENV}-graphql-@SERVICE@.theorchard.io/graphql

docker rmi -f ${ECR_REPOSITORY}:${GIT_COMMIT}
</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <jenkins.plugins.slack.SlackNotifier plugin="slack">
      <baseUrl></baseUrl>
      <teamDomain>orcd</teamDomain>
      <authToken></authToken>
      <tokenCredentialId>@SLACK_CREDENTIAL_ID@</tokenCredentialId>
      <botUser>false</botUser>
      <room>@SLACK_ROOMS@</room>
      <startNotification>false</startNotification>
      <notifySuccess>false</notifySuccess>
      <notifyAborted>false</notifyAborted>
      <notifyNotBuilt>true</notifyNotBuilt>
      <notifyUnstable>true</notifyUnstable>
      <notifyRegression>false</notifyRegression>
      <notifyFailure>true</notifyFailure>
      <notifyBackToNormal>true</notifyBackToNormal>
      <notifyRepeatedFailure>false</notifyRepeatedFailure>
      <includeTestSummary>false</includeTestSummary>
      <includeFailedTests>false</includeFailedTests>
      <commitInfoChoice>AUTHORS_AND_TITLES</commitInfoChoice>
      <includeCustomMessage>true</includeCustomMessage>
      <customMessage>Commit Sha $GIT_COMMIT</customMessage>
      <customMessageSuccess></customMessageSuccess>
      <customMessageAborted></customMessageAborted>
      <customMessageNotBuilt></customMessageNotBuilt>
      <customMessageUnstable></customMessageUnstable>
      <customMessageFailure></customMessageFailure>
    </jenkins.plugins.slack.SlackNotifier>
  </publishers>
  <buildWrappers>
    <org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper plugin="credentials-binding">
      <bindings>
        <org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
          <credentialsId>apollo-engine-graphql-theorchard-api-key</credentialsId>
          <variable>APOLLO_ENGINE_API_KEY</variable>
        </org.jenkinsci.plugins.credentialsbinding.impl.StringBinding>
      </bindings>
    </org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper>
  </buildWrappers>
</project>
