Reference: http://docs.aws.amazon.com/codebuild/latest/userguide/getting-started.html
--The git command can be executed.
nothing special
bash:Variable setting:
DIR_WORK="${HOME}/src-codebuild-demo-java"
bash:command:
mkdir -p ${DIR_WORK}/src/{main,test}/java \
        && cd ${DIR_WORK}/
bash:command:
FILE_INPUT='src/main/java/MessageUtil.java'
bash:command:
cat << EOF > ${FILE_INPUT}
public class MessageUtil {
  private String message;
  public MessageUtil(String message) {
    this.message = message;
  }
  public String printMessage() {
    System.out.println(message);
    return message;
  }
  public String salutationMessage() {
    message = "Hi!" + message;
    System.out.println(message);
    return message;
  }
}
EOF
cat ${FILE_INPUT}
bash:command:
FILE_INPUT='src/test/java/TestMessageUtil.java'
bash:command:
cat << EOF > ${FILE_INPUT}
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.assertEquals;
public class TestMessageUtil {
  String message = "Robert";
  MessageUtil messageUtil = new MessageUtil(message);
  @Test
  public void testPrintMessage() {
    System.out.println("Inside testPrintMessage()");
    assertEquals(message,messageUtil.printMessage());
  }
  @Test
  public void testSalutationMessage() {
    System.out.println("Inside testSalutationMessage()");
    message = "Hi!" + "Robert";
    assertEquals(message,messageUtil.salutationMessage());
  }
}
EOF
cat ${FILE_INPUT}
bash:command:
FILE_INPUT='pom.xml'
bash:command:
cat << EOF > ${FILE_INPUT}
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.example</groupId>
  <artifactId>messageUtil</artifactId>
  <version>1.0</version>
  <packaging>jar</packaging>
  <name>Message Utility Java Sample App</name>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
EOF
cat ${FILE_INPUT}
bash:command:
xmllint --noout ${FILE_INPUT}
If nothing is displayed, it's OK.
bash:command:
git init
bash:Variable setting:
GIT_ADDR='<mail address>'
bash:command:
git config --global user.email "${GIT_ADDR}"
bash:Variable setting:
GIT_NAME='Your Name'
bash:command:
git config --global user.name "${GIT_NAME}"
bash:command:
git add .
bash:command:
git commit -m 'created repository.'
bash:command:
git log
Result (example):
  commit 95d8522773831827702fe9841aff4c33acb7f514
  Author: Your Name <[email protected]>
  Date:   Sun Apr 17 12:38:37 2017 +0000
      created repository.
Recommended Posts