Continuous Integration

This are all steps you need to insert.

You must complete "Preparing Jenkins for first use" before this job.

  1. Create a new Job
  2. Link your repository to this Job (Source Code Management)
  3. Check "build when a change is pushed to TFS/ Team Services" (Build Triggers)
  4. Check "environment variables to the build process" and add at leest the next variables.

    DOCKER_REPO_NAME = Repository's name.
    DOCKER_IMAGE_NAME = dockerImage (node:latest)
    DOCKER_CONTAINER_NAME = your docker container's name (Docker-test)
    REMOTE_SSH_SERVER = Ssh direcction ([email protected])
    REMOTE_SSH_SERVER_DIRECTORY = Ssh server directory (/home/asdel)
    EXTERNAL_PORT = External Docker container port (8080)
    INTERNAL_PORT = External host port (49160)
    
  5. Inject passwords to the build as environment variables
    Insert here your "VSTS_NPM_AUTH_TOKEN".

  6. Add 2 Shell script on remote host using SSH step
    On Jenkins Host, run:

cd $JENKINS_WORKSPACE && \
docker rmi -f $(docker images | grep "^<none>" | awk "{print $3}")  || true  && \
docker build -t ${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME}  --force-rm --build-arg VSTS_NPM_AUTH_TOKEN=${VSTS_NPM_AUTH_TOKEN} . && \
docker save ${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME} > ${DOCKER_IMAGE_NAME}.tar && \
scp ${DOCKER_IMAGE_NAME}.tar ${REMOTE_SSH_SERVER}:${REMOTE_SSH_SERVER_DIRECTORY}

On specifed Docker Host, run:

cd $JENKINS_WORKSPACE \
&& docker rmi -f $(docker images | grep "^<none>" | awk "{print $3}")  || true \
&& docker build -t ${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME}  --force-rm --build-arg VSTS_NPM_AUTH_TOKEN=${VSTS_NPM_AUTH_TOKEN} . \
&& docker save ${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME} > ${DOCKER_IMAGE_NAME}.tar \
&& scp ${DOCKER_IMAGE_NAME}.tar ${REMOTE_SSH_SERVER}:${REMOTE_SSH_SERVER_DIRECTORY} \

results matching ""

    No results matching ""