Continuous Integration
This are all steps you need to insert.
You must complete "Preparing Jenkins for first use" before this job.
- Create a new Job
- Link your repository to this Job (Source Code Management)
- Check "build when a change is pushed to TFS/ Team Services" (Build Triggers)
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)
Inject passwords to the build as environment variables
Insert here your "VSTS_NPM_AUTH_TOKEN".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} \